-
Notifications
You must be signed in to change notification settings - Fork 769
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
Feat(parser): improved comment parsing #1956
Conversation
improved comment parsing for INSERT, UPDATE, and DELETE added tests with and w/o CTEs
The build process is complaining about this line:
I am trying to make sure comments either has elements or - if the list is empty - is set to I do not know how to make mypy happy, help is appreciated. |
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.
LGTM, thanks! Maybe we should also test the SQL generation for these comments?
I am trying to make sure comments either has elements or - if the list is empty - is set to None. I do not know how to make mypy happy, help is appreciated.
You can also just inline it in the self.expression
call:
return self.expression(
exp.Insert,
comments=comments,
...
You don't need to set comments
to None
if it's an empty list, the expression
method doesn't care if it's None
or []
.
Sadly, in all cases, the comments are moved to the end, instead of at the beginning. I am not even sure, how select_sql achieves comments in front in the generator. |
make mypy happy
There's a flag in the generator that controls this, it's called |
Added indentity examples: /* comment1 */ INSERT INTO x /* comment2 */ VALUES (1, 2, 3) /* comment1 */ UPDATE tbl /* comment2 */ SET x = 2 WHERE x < 2 /* comment1 */ DELETE FROM x /* comment2 */ WHERE y > 1
improved comment parsing for INSERT, UPDATE, and DELETE
added tests with and w/o CTEs