Skip to content

Conversation

akirk
Copy link
Member

@akirk akirk commented Jul 19, 2024

Before this the unit test failed.

cc @JanJakes

')'
);

$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 👍

@JanJakes
Copy link
Member

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
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