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

fix(db_api): use sqlparse to split DDL statements #372

Merged
merged 2 commits into from
Jun 22, 2021

Conversation

IlyaFaer
Copy link
Contributor

@IlyaFaer IlyaFaer commented Jun 17, 2021

Instead of simple str.split(";") method use more smart sqlparse package to split DDL statements executed in a form:

cursor.execute("""
    ddl_statement1;
    ddl_statement2;
    ddl_statement3;
""")

@IlyaFaer IlyaFaer added api: spanner Issues related to the googleapis/python-spanner API. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Jun 17, 2021
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Jun 17, 2021
@IlyaFaer
Copy link
Contributor Author

According to what I see in the sqlparse source code and documentation, it should work okay with GoogleSQL. Plus to the test case I've tried several types of DDL statements (interleaved tables, alters, indexes - cases, which seems complex to me). All was splitted correсtly.

@IlyaFaer IlyaFaer marked this pull request as ready for review June 17, 2021 09:18
@IlyaFaer IlyaFaer requested a review from a team as a code owner June 17, 2021 09:18
@IlyaFaer IlyaFaer requested a review from larkee June 17, 2021 09:18
@larkee larkee added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jun 21, 2021
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jun 21, 2021
@larkee larkee added automerge Merge the pull request once unit tests and other checks pass. kokoro:force-run Add this label to force Kokoro to re-run the tests. labels Jun 22, 2021
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jun 22, 2021
@gcf-merge-on-green gcf-merge-on-green bot merged commit ed9e124 into googleapis:master Jun 22, 2021
@gcf-merge-on-green gcf-merge-on-green bot removed the automerge Merge the pull request once unit tests and other checks pass. label Jun 22, 2021
@IlyaFaer IlyaFaer deleted the split_ddls branch June 22, 2021 07:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the googleapis/python-spanner API. cla: yes This human has signed the Contributor License Agreement. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants