Skip to content

Commit

Permalink
fix: implement concatenation for string and null value
Browse files Browse the repository at this point in the history
fixes #956
  • Loading branch information
leifg committed Mar 1, 2023
1 parent 2201c31 commit 00e19b7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ export const sf$add = (value1, value2) => {
);
case 'text text':
return buildLiteralFromJs(value1.value + value2.value);
case 'text null':
return value1;
default:
ArgumentError.throwWrongType('add', 'number', value2.dataType);
}
Expand Down
6 changes: 6 additions & 0 deletions test/functions.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,12 @@ describe('add', () => {
});
});

context('Text, Null', () => {
it('concats correctly', () => {
expect(dispatch('add', [buildLiteralFromJs('Black'), buildLiteralFromJs(null)])).to.deep.eq(buildLiteralFromJs('Black'));
});
});

context('Date, Number', () => {
it('adds number of days', () => {
expect(dispatch('add', [buildDateLiteral(2020, 2, 11), buildLiteralFromJs(5)])).to.deep.eq(buildDateLiteral(2020, 2, 16));
Expand Down

0 comments on commit 00e19b7

Please sign in to comment.