Skip to content

Commit

Permalink
Merge pull request #201 from rlaiola/datefix
Browse files Browse the repository at this point in the history
Fix wrong date format crash
  • Loading branch information
evazangerle authored Jun 27, 2024
2 parents b9414f4 + 88c04fa commit 69808a3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/db/exec/ValueExpr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,8 @@ export class ValueExprGeneric extends ValueExpr {
return true;

case 'date':
// Check wether the date format is valid
this._parseIsoDate(this._args[0]._args[0]);
return this._checkArgsDataType(schemaA, schemaB, ['string']);

case 'adddate':
Expand Down
11 changes: 11 additions & 0 deletions src/db/tests/translate_tests_ra.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1073,6 +1073,17 @@ QUnit.test('pi with eval: date', function (assert) {
assert.deepEqual(result, reference);
});

QUnit.test('pi with wrong date format', function (assert) {
try {
const query = "pi date('01-01-1970')->d (R)";
exec_ra(query, getTestRelations());
assert.ok(false);
}
catch (e) {
assert.ok(true);
}
});

QUnit.test('pi with eval: upper()', function (assert) {
const relations = getTestRelations();
const result = exec_ra(" sigma x < 'D' pi upper(S.b)->x S ", relations).getResult();
Expand Down

0 comments on commit 69808a3

Please sign in to comment.