Skip to content

Add support for mysql CTEs. #1188

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

Merged
merged 6 commits into from
Sep 15, 2021
Merged

Add support for mysql CTEs. #1188

merged 6 commits into from
Sep 15, 2021

Conversation

zelch
Copy link
Contributor

@zelch zelch commented Sep 15, 2021

This brings in the current version of github.com/pingcap/parser, fixes rename support (altered in the newer version of parser), and then adds support for mysql CTEs that exists in the newer version of parser.

This also creates mysql versions of all of the existing CTE test cases, the only things that had to be changed for those test cases from the stdlib test cases was setting the engine, and changing the parameter style from $1 to ?.

Zephaniah E. Loss-Cutler-Hull added 6 commits September 14, 2021 17:49
This is needed as CTE support is fairly new for the parser.
pcast.RenameTableStmt was modified in the current parser to only have
the list of renames, instead of both a single set of data for renames
and the list.

As such we need to turn that into an ast.List of ast.RenameTableStmt.
The mysql code now uses an ast.List for all rename statements, however
Catalog.Update ignores ast.List items instead of walking through them,
this results in the renames getting lost.

This change causes us to go through each list, assuming that they may
contain statements.
These will be used by the different types that have With objects.
This should give us full support for CTEs (recursive and not) for mysql.

All types that parser has With entries for, and which we currently
support, are handled here.
This just copies the stdlib test cases to mysql, sets the engine, and
switches to mysql style parameters.

Otherwise, no changes to the tests or the expected test output.
@kyleconroy kyleconroy merged commit 6fdb7e1 into sqlc-dev:main Sep 15, 2021
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.

2 participants