-
Notifications
You must be signed in to change notification settings - Fork 38
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
Ensure that an index is also created using IF NOT EXISTS if it comes from a CREATE TABLE IF NOT EXISTS #134
Conversation
…index if not exists
@@ -888,6 +888,8 @@ private function execute_create_table() { | |||
')' | |||
); | |||
|
|||
$if_not_exists = false === strpos( $create_query, 'IF NOT EXISTS' ) ? '' : 'IF NOT EXISTS'; |
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.
@akirk, something just occurred to me that probably affects other parts of this plugin as well:
Aren't these keywords case insensitive, and if so, we should probably make the check case insensitive.
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.
Well, there is also potential whitespace deviations. Either we normalize the output here, or we use a regex with \s+
instead of spaces.
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 could also use stripos
instead of strpos
to make this case-insensitive... I'd rather we limit the use of regex if not absolutely necessary.
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.
But what if someone writes if NOT exists
? One other option is to change get_updated_query()
so that it will return normalized SQL, like unify whitespace, uppercase lexer tokens, then we can just use strpos
.
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.
Fair point 👍
Co-authored-by: Brandon Payton <brandon@happycode.net>
Is this one good to go now? I've seen the issues were addressed in 95499b2. |
Before this the unit test failed.
cc @JanJakes