Skip to content

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

Merged
taylorotwell merged 1 commit into
laravel:9.xfrom
markuskooche:9.x
Apr 25, 2022
Merged

[9.x] Support 'IS' and 'IS NOT' PostgreSQL operators#42123
taylorotwell merged 1 commit into
laravel:9.xfrom
markuskooche:9.x

Conversation

@markuskooche

Copy link
Copy Markdown
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.

2 participants