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

Allow ['column' => [value, NULL]] as short syntax for column = value OR column IS NULL #927

Closed
levu42 opened this issue Sep 15, 2020 · 1 comment

Comments

@levu42
Copy link

levu42 commented Sep 15, 2020

I have to check for a column being either a specific value or NULL. The current way to do it I found is:

['OR' => ['AND #1' => ['column' => 42], 'AND #2' => ['column' => null]]]

But it would be so much nicer to just write

['column' => [42, null]]

This code currently gives you

column IN (42, null)

which at least in MariaDB doesn't work. My suggestion is to change the IN() generation code in a way that the SQL generated becomes

column IN (42) OR column IS NULL

@catfan
Copy link
Owner

catfan commented Sep 15, 2020

This will be confusing.

Think about:

  • If the first condition is not a value but array. ["column" => [42, 43, 44, 45....]]
  • If we want the NOT null condition ["column[!]" => null]

It's no need to combine, and will be conflict for the general usage. ["column" => [value1, value2...]]

@catfan catfan closed this as completed Apr 25, 2021
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

No branches or pull requests

2 participants