-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add all "type reserved" MySQL keywords #106
Conversation
807424e
to
dd64ad1
Compare
c51682a
to
3af69d8
Compare
8c20a13
to
13a1826
Compare
19b74f2
to
f0d6aab
Compare
3000378
to
33ba5c0
Compare
Please address the color/format changes in the test output and how these are necessary for adding reserved keywords in this PR. |
@SenseException Here is an explanation - some keywords like Is this explaining your question or do you observed anything specific you want to have answered more in depth? |
src/Tokenizer.php
Outdated
@@ -22,62 +23,57 @@ | |||
final class Tokenizer | |||
{ | |||
/** | |||
* Reserved words (for syntax highlighting) | |||
* Reserved MySQL and MariaDB keywords |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When reading that, one might think they shouldn't add keywords for any other DB… is that the case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes - and this is also strictly tested using testKeywordsReservedAreStrictlyMysqlAndMariadbReserved
test. The reason is we must be sure the "reserved" keywords are really "reserved", as only these keywords can be uppercased safely - for #32. All other keywords must be put into "non-reserved" list, even if they are "reserved" in other than MySQL/MariaDB DB vendor.
In practise, this is very clever, as generic SQL keywords (like WHERE
, UPDATE
, ...) are reserved everywhere and exotic keywords can be still highlighted using the "non-reserved" list but their case must be kept to prevent #95.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there keywords that could be reserved according to MariaDB, but not according to other vendors? I don't get why MySQL/MariaDB is privileged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reasons are historical, jdorn library was based on MySQL keywords solely.
I already added full SQLite reserved keywords list to the tests so all of them are newly contained in the "non-reserved" list.
This PR aims to add MySQL/MariaDB/SQLite keywords. Other vendors can be added later.
For highlighting, "reserved"/"non-reserved" lists are used the same way. For #32, we need "reserved" list to be minimal subset (intersect) of all vendors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there keywords that could be reserved according to MySQL/MariaDB, but not according to other vendors? If yes, what did you do with these keywords?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I ask a question, answer that question. Don't answer another question, or if you don't know, just say so. So for the third time, "Why did you make me ask 3 times?" I want a honest and plausible answer, is that too much to ask?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to answer your question in my 1st answer with some explanation...
So are we on the same page now? Is here anything else actionable I should amend in this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to answer your question in my 1st answer with some explanation...
Really? Let's see…
The question was:
Are there keywords that could be reserved according to MySQL/MariaDB, but not according to other vendors?
You answered:
The reasons are historical, jdorn library was based on MySQL keywords solely.
This feels more like an answer to the second question, which was:
I don't get why MySQL/MariaDB is privileged.
Then you went on with:
I already added full SQLite reserved keywords list to the tests so all of them are newly contained in the "non-reserved" list.
Still aimed at the second question
This PR aims to add MySQL/MariaDB/SQLite keywords. Other vendors can be added later.
Still aimed at the second question as well
For highlighting, "reserved"/"non-reserved" lists are used the same way. For #32, we need "reserved" list to be minimal subset (intersect) of all vendors.
Interesting, but does not have to do with any of the 2 questions.
So are we on the same page now?
Well… no! You said you tried to answer your question in your first answer, but I think I just demonstrated that you completely ignored it. It feels like we live in separate realities.
Is here anything else actionable I should amend in this PR?
One thing at a time please. Before I invest more time in this PR, I'd like to understand if you are deliberately wasting my time or not.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@greg0ire Thank you your feedback helped me to realize few important facts and I have reworked this PR.
I have removed the ambiguous "reserved" vs "non-reserved" categorization and added exact "reserved" keyword list for each major DB vendor.
Let me please know what you think and if I should possibly extract some commit into separate PR.
33ba5c0
to
edc05c4
Compare
Minimize diff for next commits, non functional change.
Functions are always case insensitive and cannot contain a whitespace.
c843eba
to
1cfcac2
Compare
"reserved" keyword is tokenized sooner thus the same keyword defined as "function" is useless.
To fix all type highlighting in function tests.
26064d6
to
b34f582
Compare
For future compilation of Tokenizer lists. Also test if all intersected keywords are really reserved.
b34f582
to
1c0187f
Compare
]; | ||
|
||
/** | ||
* Based on https://www.postgresql.org/docs/16/sql-keywords-appendix.html list. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That link looks like a copy/paste, but maybe that's normal? First time I hear about sql2023.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PostgreSQL link is intended there as the SQL:2023 spec is non-public/paid - I find PostgreSQL as quite reputable source and then I cross verified it againts https://en.wikipedia.org/wiki/List_of_SQL_reserved_words. Is the actual comment fine or should I update it in any way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's fine, just wanted to make sure.
Into 1.4.x as this is bugfix.
Also add reserved keyword lists for major DB vendors for future "non-reserved" (keywords that do not have to be quoted) lists compilation.