sea-orm
sea-orm copied to clipboard
Adding `filter`s after adding a `Condition::any` in another call results in `OR` instead of `AND`
Description
When querying data, adding a filter using a Condition::any causes any further calls to filter to also be part of that any condition.
Steps to Reproduce
- Create a query with a filter using a
Condition::any - Add another condition in a separate call to
filter
Expected Behavior
I'd expect this:
Entity::find()
.filter(
Condition::any()
.add(Column::Field2.eq("dog"))
.add(Column::Field3.eq("dog")),
)
.filter(Column::Field1.eq(1))
to be equivalent to this:
Entity::find()
.filter(Column::Field1.eq(1))
.filter(
Condition::any()
.add(Column::Field2.eq("dog"))
.add(Column::Field3.eq("dog")),
)
Actual Behavior
The first produces:
SELECT `table`.`field1`, `table`.`field2`, `table`.`field3` FROM `table` WHERE `table`.`field2` = 'dog' OR `table`.`field3` = 'dog' OR `table`.`field1` = 1
While the second produces the expected output of:
SELECT `table`.`field1`, `table`.`field2`, `table`.`field3` FROM `table` WHERE `table`.`field1` = 1 AND (`table`.`field2` = 'dog' OR `table`.`field3` = 'dog')
Reproduces How Often
Every time
Versions
sea-orm v0.9.1
├── sea-orm-macros v0.9.1 (proc-macro)
├── sea-query v0.26.2
│ ├── sea-query-derive v0.2.0 (proc-macro)
│ ├── sea-query-driver v0.2.0 (proc-macro)
├── sea-strum v0.23.0
│ └── sea-strum_macros v0.23.0 (proc-macro)
Ubuntu 22.04 on WSL in Windows 11