-
Notifications
You must be signed in to change notification settings - Fork 127
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
Handle binary char set introducer #544
Conversation
Others are not supported yet :c
By now, it's the only one parsed charset.
[skip ci]
tests/test.py
Outdated
id = get_random_id() | ||
# DON'T EVER, EVER DO THIS | ||
# Do not use direct string interpolation for sql values | ||
# This is just a test example |
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.
we can avoid using raw sql and build query with sqlalchemy:
>>> from sqlalchemy.sql import expression
>>> from sqlalchemy.sql import operators
>>> unary = expression.UnaryExpression(
sa.Column("column"),
operator=operators.custom_op("_binary"),
type_=sa.Numeric)
>>> str(unary)
'_binary "column"'
Use unary
instead of self.test_table.c.value_bytes
Sqlalchemy serializes the test as: ``` INSERT ... VALUES (..., (_binary 'string')...) ``` So it's easier to add support also for parenthese expressions, than fight with sqlalchemy. The syntax in general [1] is defined as: ``` simple_expr: | (expr [, expr] ...) ... ``` But our parser supports only: ``` simple_expr: | (expr) ... ``` Which is enough for most real word cases. Therefore, it's easy to add support for these expressions. [1]: https://dev.mysql.com/doc/refman/8.0/en/expressions.html
|
||
self.schema_table.create(bind=self.engine_raw, checkfirst=True) | ||
id = get_random_id() | ||
insert = self.test_table.insert().values( |
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.
hm, if sqlalchemy compile query with parentheses, then lets test them both? and use raw sql query to use without parentheses if sqlalchemy doesn't allow compile without them
To use both: with and without parentheses around literal.
This small PR adds support of mysql _binary charset introducer, which is used at least by java frontend. I would like to add other charsets, but they are not supported by the parser yet. So, if there is no need, I wouldn't do that.
Checklist
with new changes
CHANGELOG.md is updated (in case of notable or breaking changes)Benchmark results are attached (if applicable)Example projects and code samples are up-to-date (in case of API changes)