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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various improvements: aggregate functions, insert set syntax, & update join syntax #68

Merged
merged 5 commits into from
Jan 23, 2023

Conversation

DerekStride
Copy link
Owner

@DerekStride DerekStride commented Jan 20, 2023

What

There are 3 updates that fix the issues described in #67.

cc// @LeoniePhiline

Update insert to support SET syntax

3f08080
2fdc428

Also updates the values branch of the grammar to allow for specifying multiple lists of items. The other commit includes support for the postgres style update statement.

Rework special cases for aggregate functions

8c0ca86
61c6e23

Previous to this commit count was a special case node. It worked a lot like the invocation node but had some custom grammar rules.

This commit introduced another special case node, group_concat. According to the MySQL reference there might not be many more like this but to provide a pattern for the future I moved both count & group_concat into a special anonymous node called _aggregate_functions.

The other commit adds the _aggregate_expression node from the suggestions.

Consolidate UPDATE rules into 1 node

3b82416

Previously there was separate anonymous nodes for single table & multi table update statements. This commit merges them into a single node and reworks them to support the JOIN syntax.

@DerekStride DerekStride requested a review from dmfay January 20, 2023 22:32
@DerekStride DerekStride self-assigned this Jan 20, 2023
@DerekStride DerekStride linked an issue Jan 20, 2023 that may be closed by this pull request
@DerekStride DerekStride changed the title Ds/various improvements Various improvements: aggregate functions, insert set syntax, & update join syntax Jan 20, 2023
@DerekStride DerekStride force-pushed the ds/various-improvements branch from 77e901a to 0efb1c0 Compare January 20, 2023 22:34
@LeoniePhiline
Copy link
Contributor

Wow @DerekStride, kudos to you!

This quick and comprehensive response by far exceeds all my expectations!

I will test your branch as well, to confirm the fixes.

Copy link
Collaborator

@dmfay dmfay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couple things to think about but it looks good in general!

@@ -1000,6 +990,11 @@ module.exports = grammar({
')',
),

_aggregate_function: $ => choice(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great!

* Also updates the values branch of the grammar to allow for specifying
  multiple lists of items.
Previous to this commit `count` was a special case node. It worked a lot
like the `invocation` node but had some custom grammar rules.

This commit introduced another special case node, group_concat.
According to the MySQL reference there might not be many more like this
but to provide a pattern for the future I moved both count &
group_concat into a special anonymous node called
`_aggregate_functions`.

https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html
Previously there was separate anonymous nodes for single table & multi
table update statements. This commit merges them into a single node and
reworks them to support the JOIN syntax.
* Postgres supports a from-clause after the assignment list in the `set`
  clause.
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.

SQL highlighting issue in helix-editor, using tree-sitter-sql
3 participants