Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SQL] Many fixes and improvements overall #3304

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

azizk
Copy link
Contributor

@azizk azizk commented Apr 2, 2022

Hey!

My main goal was to fix the way the word-boundary escape \b is used throughout the syntax file. I did much more besides that.
So I wanted, for example, 1IN to be two tokens, and I assumed that every engine recognizes them as such, but I just tested with PSQL and MySQL and it looks like it's 2 tokens for PSQL and 1 for MySQL.

-- This is valid in PSQL and returns `true`. MySQL thinks it's an undefined function called "1IN".
SELECT 1IN(1,2,3);

I haven't looked at what the standard says yet. Regardless, I think my changes are pretty useful as they are and the thing above can be reverted by adding a \b back to the match: \d+ context. My last commit is solely for formatting. Hope you like it! 馃憤

@deathaxe
Copy link
Collaborator

deathaxe commented Apr 2, 2022

Many thanks to your contribution. I wonder whether we can incooperate any valuable changes into #3046 as it already comes a long with a lot of improvements especially with regards to syntaxes for different SQL dialects based on one "root-syntax".

@azizk
Copy link
Contributor Author

azizk commented Apr 2, 2022

Oh dear, I should have done a search before doing this. 馃槃
I'll check it out later...

@azizk azizk force-pushed the azizk/sql-fixes branch 2 times, most recently from 0ce0243 to b1ff4dc Compare April 3, 2022 11:22
@jrappen
Copy link
Contributor

jrappen commented Apr 5, 2022

Yes, as @deathaxe said, please take a look at @keith-hall 's #3046. As you can see, his branch for that PR is https://github.com/forkeith/Packages/tree/sql which you can use for a diff and/or possible PRs to target and be included in #3046.

@azizk
Copy link
Contributor Author

azizk commented Apr 6, 2022

Thanks @jrappen! Yeah I checked it out and it's looking great. There are some things I'd do differently (the leading \b) and I could also contribute some more stuff, which isn't included in this PR (mostly PostgreSQL). Hey @keith-hall, if you're interested I could contribute and send a PR to your branch. 馃憤

Nevertheless, do you all think it's still worthwhile to merge this in? I don't mind if it's overwritten later by Keith's work, but until then these changes may be useful and deployed to users earlier? 馃槂

SQL/SQL.sublime-syntax Outdated Show resolved Hide resolved
@keith-hall
Copy link
Collaborator

a PR to my branch improving PostgreSQL would be very welcome :)
I'm not sure I agree with the blanket removal of leading \b though. It would make sense to do this for the PSQL variant, sure, but it'd be nice to keep it for the others, so even though merging this PR early could be beneficial for PSQL users, it may be a regression for all others.

@azizk
Copy link
Contributor Author

azizk commented Apr 10, 2022

@keith-hall Alright, gonna send some commits then. 馃槂
So regarding the leading word anchor \b, afaics it's not necessary. It's only needed if you don't consume all the word characters (the way it is now), but if you do then using a leading \b everywhere is pretty redundant. Or maybe I'm overlooking something? And in case you want to recognise something like 1IN as a single token, like I described in my PR comment, then adding a trailing \b to the number regexp is all there is to make it work.

SQL/SQL.sublime-syntax Outdated Show resolved Hide resolved
@jrappen
Copy link
Contributor

jrappen commented May 8, 2022

What's the current status with this PR and the request to add your changes to Keith's PR?

So far you have only renamed some stuff on Keith's branch and not added any meaningful changes from this PR to his.

@azizk
Copy link
Contributor Author

azizk commented May 8, 2022

@jrappen From my end the PR here can go in. Keith is concerned about the leading \b however. I asked about it in my previous comment...
I know I only contributed minor things on his branch. I haven't committed my other progress yet. Just had other priorities in the meantime.

* It doesn't recognize grammatically valid expressions like this:
  `SELECT * FROM t WHERE 1IN t.list`
* Removed trailing \b from `\d+` as well for the same reason.
Replace trailing `\s+` with a `\b`.
Add some missing trailing `\b`.
Also allow spaces between database name, `.` and table name.
Also: give schema ids their own scope.
Don't assign storage.type.sql to whitespace.
@azizk
Copy link
Contributor Author

azizk commented Aug 27, 2022

I just rebased the branch. If the PR is still useful please merge, otherwise let's close it. I'm lacking the time and resources to continue with this...

@jrappen
Copy link
Contributor

jrappen commented Aug 28, 2022

鈿狅笍 Not sure why changing the pops but not updating to sublime syntax v2 didn't break the tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants