-
Notifications
You must be signed in to change notification settings - Fork 59
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
refactor: consolidate table_reference and invocation identifier into object_reference #150
Conversation
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.
Looks good. I like the new _dml_*
structure
grammar.js
Outdated
'.', | ||
), | ||
), | ||
choice( |
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.
this is a choice of just one element.
@@ -625,7 +642,7 @@ module.exports = grammar({ | |||
optional( | |||
$.keyword_only, | |||
), | |||
$.table_reference, | |||
$.object_reference, |
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.
We should not forget to fix the queries downstream in nvim-treesitter. There is a query matching on table_reference
The test
I do not understand why this has been changed from |
I have a variant of your branch, where only two tests fail (Simple select with schema and fully-pathed fields, insert with field name). Should I push it to this PR? |
yes absolutely!
I didn't follow up on MySQL multi-table updates (where the lhs can be qualified) until later and forgot to undo that change. I'll wait to change anything until you've pushed your updates though. |
Not so many changes. I played around with your changes a bit. The last two tests are breaking because of L1308 - The other one is the fully qualified object_ref. LL1260 [Edit]: I did not comment all in in L1308. Now it is just one test failing, and thats the fully qualified path fields. |
Now I stumbled over your comments before |
some experimenting here in a toy subset https://github.com/dmfay/tsqltest this gets sch.tbl.field, sch.tbl.* (missing a test in main atm!), etc correctly in select clauses but breaks join predicates, order columns, and so on when transferred to the full tree-sitter-sql since I think it is promising or at least a hopeful sign though! I'll keep looking into this |
failures now are from tree-sitter resolving multiple values, e.g a binary_expression with a qualified lhs winds up with multiple `left` value attributes
okay I'm alive! Lots of progress here -- actually the object_reference move is complete, and the remaining issue I can see is with the various optimize statements added in the interim. As pushed this doesn't compile, complaining about conflicts first in The |
I don't understand why we have conflicts here at all. I mean What do you mean by "lifting into named/anonymous rules"? |
because the anomalous |
I think it's because of how we structure programs as sequential statements and often have optional That seems like a bit much to try to tackle here so I've added a conflict for _vacuum_table and _compute_stats which lets it compile for now. All tests pass, but we should revisit |
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.
This is awesome. I really like that we have a clearer structure now.
There 3 comments, two of them are just about comments in the code.
grammar.js
Outdated
// TODO i don't think we have a test for `insert into tbl set ....` and | ||
// it's no dialect i can think of |
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.
If I read the docs correclty, then MariaDB allows for this:
https://mariadb.com/kb/en/insert/
@@ -2092,26 +2101,29 @@ module.exports = grammar({ | |||
), | |||
optional($.where), | |||
optional($.group_by), | |||
optional($.window_clause), |
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.
is is correct that the window_clause can be between group_by and order_by? Does the order matter here? I thought that is should be last.
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 followed Postgres in placing it between having
and order by
. I haven't seen another product with a standalone window
clause.
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 does make sense as limit
and order by
apply to the result of set operations (union, intersect, except) & you can see those are a dividing line
Incorporates #149 ; not ready for primetime yet, there are four test failures that mostly stem from incorrect precedence negotiation between
object_reference
andfield
-- give it a whirl if you have time!@matthias-Q if this is too much (it's a lot) you can avoid a lot of the precedence-setting in #149 by setting it in
parametric_type
as here. It still wants the precedence onrelation
but I haven't gone too far down that rabbit hole yet.