Add support for MSSQL bracket quoted identifiers #20
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "main"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This PR adds support for the MSSQL specifc style of quoting identifiers using square brackets.
i.e. in select [u].[Name] from [dbo].[Users] [u] the schema identifiers or aliases in brackets are now correctly recognized as QuotedIdentifiers. This then also makes the schema completion source work as normal with this syntax style.
The unit tests I added should reflect all relevant cases.
To bring the identifierQuotes property in line I decided to simply hard match the bracket pair.
So the identifierQuotes need to be explicitly set to '[' in order to correctly generate the completions wrapped in square brackets.
For me this seemed like the simplest and least intrusive solution, but I'm also open to other suggestions on how this should be implemented.
What the reason behind having a separate
mssqlBracketQuotingMechanismfield when it sounds like that could be derived from[being present inidentifierQuotes?(Also, please put
elseon the line of the closing bracket for theifbranch, for consistency with the rest of the code.)I made them seperate to not unnecessarily restrict the configuration.
This way one could configure other quotes to be used in completion, but still benefit from bracket quoted identifiers being correctly highlighted and generally recognized as such.
I cannot really think of a situation where you'd want these to be parsed but not handled by completion, or the other way around. But I see you're not adding
[toidentifierQuotesin the definition ofMSSQL. But then adding them back in in a test. Why is that? Am I missing something?Ah, I got confused by how the completionSource only ever reads the first character and missed the actual usage in the parser.
So yes, I guess it could also be done like this:
Then if you want you could redefine the dialect to put the bracket in the first spot so the completion source uses them as default when quoting completions.
Or maybe I'm missing something else and theres actually a different way to do this?
The parser would still need to handle this case before it accepts the bracket as just a bracket.
So either add this into the block for BracketL or move the QuotedIdentifier block up and add it there. Not sure if the second option would break something though.
Yes, that's what I was thinking as well.
The latter sounds most reasonable.
Alright, I have added this adjustment
Looks mostly good now. Could you remove the meaningless changes that your IDE or linter made (just adding a comma) to reduce patch noise?
Thanks, merged! I noticed some random semicolons, which I removed myself in
3dc83af(Let me know whether you're planning any other patches. If not I'll cut a release.)
Great, and thank you!
No, I don't plan on anything else. So a release would be appreciated.
Tagged 6.10.0