Add _all_ date function aliases to parser (extended)#1982
Add _all_ date function aliases to parser (extended)#1982paulrutter wants to merge 11 commits intoAlaSQL:developfrom
Conversation
- Add all other AlaSQL date functions and aliases to the parser - Adjust unit tests, as month is now a reserved keyword - Explicitly didn't add the "DATE()" function, as it's use is very ambiguous in AlaSQL -> as column alias, as column type, as JS expression. - Added IntervalLiteral which contains all possible values to use when specifying an interval expression
- Use Expression instead of ExprList to restrict the number of arguments to the methods
- Extend unit test with non existing interval - DAYOFYEAR is alias for DAY
- Compact the expression with an OR statement to reduce duplicate code
|
I really like this, but im a bit sad to break lots of current implementation by making Over the Christmas break I will see if I can make this work so its only a protected keyword as the first parameter in the date functions, and other places we look for the name plus a |
|
Still working on this. Neck deep in the jungle of JISON. |
|
@mathiasrw i processed your comments and made some changes. |
|
Ill pick up the rest and work on it not being breaking. |
|
Code Quality Improvements: |
|
@mathiasrw what does the PR approval mean? Did you make progress on resolving #1982 (comment)? |
…to-parser-extended # Conflicts: # src/alasqlparser.jison # src/alasqlparser.js
|
Well, it means that im subtracting my comments to change because I am working on it locally. I think I got the last part nailed this morning. Ill confirm things over the next few days. |
|
Sounds great 👍 |
|
omg. Its already end of feb. Sorry things have been hectic. |
|
No problem, take your time 👍 |
Based on #1980, this PR attempts to add all relevant date functions to the parser (and thus validate the query for being valid).
NOWGETDATECURRENT_DATE()ADDDATE(args)SUBDATE(args)DAY(date)DAYOFMONTH(date)DAYOFWEEK(date)DATE_ADD(args)DATE_SUB(args)SUBDATE(args)MINUTE(date)SECOND(date)MONTH(date)YEAR(date)WEEK(date)WEEKDAY(date)Additional: the interval values that can be specified are now also part of the parser:
This makes some keywords now reserved keywords, like using
monthas column alias for example.This has been adjusted in this PR.
Do note that
DATE()is not added to the parser, as its use is very ambigious in AlaSQL.There are new unit tests that verify the changes made.