You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add GETDATE, NOW as alias to parser + allow CURRENT_TIMESTAMP with parenthesis #1979
We're in the process of using the AlaSQL parser to validate query syntax in our product.
The AlaSQL parser currently does not recognize the following aliases to CURRENT_TIMESTAMP (see 61date.js).
NOW
GETDATE
Also, CURRENT_TIMESTAMP is recognized by the parser, while CURRENT_TIMESTAMP() is not.
Do note that all of these functions do work in a query, the parser just cannot properly validate their use.
I'm going to supply a PR to get this fixed, which has one drawback: now, current_timestamp and getdate can no longer be used as column aliases, as they're now reserved keywords.
Ps. The same applies to other date functions like DAY() and YEAR(), but that would break far more queries (although it would be more consistent). I tried that locally a while ago. See #1937 (comment)
With the proposed PR, at least all functions for getting the current date (+time) are consistently handled.
Thanks so much for contributing! I'll merge this when we're ready to bump the major version. Since we're currently restructuring the code to be ES6-friendly, it might take a few months before we can release breaking changes.
Activity
paulrutter commentedon Oct 4, 2024
Ps. The same applies to other date functions like DAY() and YEAR(), but that would break far more queries (although it would be more consistent). I tried that locally a while ago. See #1937 (comment)
With the proposed PR, at least all functions for getting the current date (+time) are consistently handled.
mathiasrw commentedon Oct 7, 2024
Thanks so much for contributing! I'll merge this when we're ready to bump the major version. Since we're currently restructuring the code to be ES6-friendly, it might take a few months before we can release breaking changes.
mathiasrw commentedon Dec 10, 2024
Is this a duplicate of #1981?
paulrutter commentedon Dec 10, 2024
No, that seems entirely unrelated. Did you mean #1982?
#1982 indeed builds on this PR.
We could close #1980 and just go for #1982 instead, as it adds far more date functions to the parser.