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

Parser raises an exception for not supported query type when query starts with a comment #163

Closed
macbre opened this issue Jun 10, 2021 · 4 comments · Fixed by #164
Closed
Assignees
Labels

Comments

@macbre
Copy link
Owner

macbre commented Jun 10, 2021

When working on index-digest's PR I have found the following issue.

An example call:

tables = get_query_tables("/* foo */ INSERT IGNORE INTO `0070_insert_ignore` VALUES (9, '123', '2017-01-01');")

Error raised:

/* foo */ INSERT IGNORE INTO `0070_insert_ignore` VALUES (9, '123', '2017-01-01');

        if self._query_type == "UNSUPPORTED":
>           raise ValueError("Not supported query type!")
E           ValueError: Not supported query type!

env/lib/python3.9/site-packages/sql_metadata/parser.py:94: ValueError

Additionally, we should also log the query itself that caused this exception to be raised.

@macbre macbre added the bug label Jun 10, 2021
@macbre macbre added this to the v2.3 milestone Jun 10, 2021
@macbre macbre changed the title Parser raises an exception for not support query type when query starts with a comment Parser raises an exception for not supported query type when query starts with a comment Jun 10, 2021
@collerek
Copy link
Collaborator

We should probably remove the comments before the check. Didn't anticipate that but that's actually quite common, some kind of explanation what the query is doing.

You mean you want to print the whole query in exception? The query can be huge (i.e. stored procedure declaration).

@macbre
Copy link
Owner Author

macbre commented Jun 10, 2021

You mean you want to print the whole query in exception? The query can be huge (i.e. stored procedure declaration).

I'd rather log it via logger module.

@macbre macbre self-assigned this Jun 10, 2021
macbre added a commit that referenced this issue Jun 10, 2021
@macbre macbre removed this from the v2.3 milestone Jun 10, 2021
@macbre
Copy link
Owner Author

macbre commented Jun 10, 2021

Once #164 is merged I will publish v2.2.1 with this fix.

@collerek
Copy link
Collaborator

Can you check also #162 - it's small and actually simplifies handling of with clauses?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants