Skip to content

Commit 3befd34

Browse files
committed
Fix RIGHT op
1 parent 8b41c43 commit 3befd34

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/operations.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,11 @@ describe('Test parseExpression', () => {
135135
});
136136

137137
test('LEFT op', () => {
138-
expect(parseExpression('LEFT(a, b)', { a: '123456', b: 3 })).toBe('123');
138+
expect(parseExpression('LEFT(a, b)', { a: '123456', b: 2 })).toBe('12');
139139
});
140140

141141
test('RIGHT op', () => {
142-
expect(parseExpression('RIGHT(a, b)', { a: '123456', b: 3 })).toBe('456');
142+
expect(parseExpression('RIGHT(a, b)', { a: '123456', b: 2 })).toBe('56');
143143
});
144144

145145
test('EQUAL op', () => {

src/operations.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ export function parseExpression(exp: string, values: Record<string, any>): any {
133133
return String(valueA).slice(0, Number(valueB));
134134
}
135135
if (op === 'RIGHT') {
136-
return String(valueA).slice(Number(valueB));
136+
return String(valueA).slice(-Number(valueB));
137137
}
138138
// boolean
139139
if (op === 'EQUAL') {

0 commit comments

Comments
 (0)