-
Notifications
You must be signed in to change notification settings - Fork 867
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
Sql sanitizer: handle double quoted table names #5699
Sql sanitizer: handle double quoted table names #5699
Conversation
if (operation.mainTable != null && operation.mainTable.startsWith("\"") && operation.mainTable.endsWith("\"")) { | ||
operation.mainTable = operation.mainTable.substring(1, operation.mainTable.length() - 1); | ||
} |
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.
Nit: WDYT about moving this if
into the handleIdentifier()
method?
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.
Added a method that reads text matched by current token and strips double quotes and backticks.
@@ -105,6 +105,8 @@ class SqlStatementSanitizerTest extends Specification { | |||
sql | expected | |||
// Select | |||
'SELECT x, y, z FROM schema.table' | SqlStatementInfo.create(sql, 'SELECT', 'schema.table') | |||
'SELECT x, y, z FROM `schema.table`' | SqlStatementInfo.create(sql, 'SELECT', 'schema.table') |
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.
Wait, did we have backtick ` parsing?
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.
Yes, this already worked just didn't have a test.
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.
Nice 👍
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.
Actually it only works fine when you don't have a space inside backticks. If there is a space it returns the first word as the table name.
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, we don't have any special rules for backticks, I guess they're just treated as "other characters" - that maybe that behavior is caused by this?
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.
yes, hopefully fixed now.
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.
nice 👍
* Sql sanitizer: handle double quoted table names * handle backtick * strip double quotes and backtick from table name in a separate method
Resolves #5691