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

Fix logic with OR operation and add missing nil check to Like #878

Merged
merged 6 commits into from
Mar 16, 2022

Conversation

VinaiRachakonda
Copy link
Contributor

@VinaiRachakonda VinaiRachakonda commented Mar 16, 2022

MySQL has some really weird behavior where the OR of two non bools evaluates too false. Improperly handling this situation was trickling up to a LIKE panic on the new query added to queries.go

SELECT "A" OR "A";
+------------+
| "A" OR "A" |
+------------+
|          0 |
+------------+

Copy link
Contributor

@jennifersp jennifersp left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Member

@zachmu zachmu left a comment

Choose a reason for hiding this comment

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

LG but missing a test

@@ -6738,6 +6738,10 @@ var QueryTests = []QueryTest{
{1, 1, 0},
},
},
{
Query: `select (('%' || 'dsads') || '%')`,
Copy link
Member

Choose a reason for hiding this comment

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

Use OR instead of ||

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Whoops will fix

@@ -110,6 +110,10 @@ func (l *Like) Eval(ctx *sql.Context, row sql.Row) (interface{}, error) {
return nil, err
}

if likeMatcher == nil {
Copy link
Member

Choose a reason for hiding this comment

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

Where's the test for this fix?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The one in queries.go triggered this originally but I can add more.

Copy link
Member

@zachmu zachmu left a comment

Choose a reason for hiding this comment

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

LGTM

@VinaiRachakonda VinaiRachakonda merged commit 7804b74 into main Mar 16, 2022
@Hydrocharged Hydrocharged deleted the vinai/like-panic branch April 6, 2022 07:39
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.

3 participants