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

Ensure that an index is also created using IF NOT EXISTS if it comes from a CREATE TABLE IF NOT EXISTS #134

Merged
merged 3 commits into from
Aug 7, 2024

Conversation

akirk
Copy link
Member

@akirk akirk commented Jul 19, 2024

Before this the unit test failed.

cc @JanJakes

@@ -888,6 +888,8 @@ private function execute_create_table() {
')'
);

$if_not_exists = false === strpos( $create_query, 'IF NOT EXISTS' ) ? '' : 'IF NOT EXISTS';
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point 👍

aristath and others added 2 commits July 24, 2024 11:34
@JanJakes
Copy link
Collaborator

JanJakes commented Aug 6, 2024

Is this one good to go now? I've seen the issues were addressed in 95499b2.

@aristath aristath merged commit dea3efd into WordPress:develop Aug 7, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants