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

[9.x] Support 'IS' and 'IS NOT' PostgreSQL operators #42123

Merged
merged 1 commit into from
Apr 25, 2022
Merged

[9.x] Support 'IS' and 'IS NOT' PostgreSQL operators #42123

merged 1 commit into from
Apr 25, 2022

Conversation

markuskooche
Copy link
Contributor

It is not possible to use the IS or IS NOT operators for example in the whereRelation() function.
The problem is that the Illuminate\Database\Query\Builder does not support these operators.
It would work if these operators were included in this array.

https://github.com/laravel/framework/blob/9.x/src/Illuminate/Database/Query/Builder.php#L199-L206

The whereRelation() calls internally the where() function inside the Illuminate\Database\Query\Builder, which changes unsupported operators to =.

https://github.com/laravel/framework/blob/9.x/src/Illuminate/Database/Query/Builder.php#L739-L741

This is the reason why some queries raises an SQL exception.
For example for a query like this SELECT * FROM table WHERE xy IS TRUE
This is because Postgres uses real boolean values and in some cases you cannot use = 1.

Mentioned in the discussion: #42101

@markuskooche markuskooche changed the title Support 'IS' and 'IS NOT' PostgreSQL operators [9.x] Support 'IS' and 'IS NOT' PostgreSQL operators Apr 25, 2022
@taylorotwell taylorotwell merged commit 5e7492b into laravel:9.x Apr 25, 2022
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.

None yet

2 participants