Repository navigation
v1.33.0
The condition operators give the same results on every DB adapter (memory,
SQLite, PostgreSQL, MySQL), except the known differences below. Behavior
changes:
- SQL: a query through a to-many relationship returns each entity once (it
returned one per matching related row): itsJOINs are in a subquery,
id IN ( SELECT id ... JOIN ... WHERE cond ). SocountByQuery,limit
and pagination also count each entity once. - SQL: a comparison with
nullthrough a relationship (owner.level == null,=~ null,=~ [x, null], anullparameter) uses an outer join:
a missing related entity (anullowner, or no rows of a to-many
relationship) is anullfield, so it matches, as in memory, and as!=
and!~already did (since 1.32.0). It was an inner join:== null
missed it while!= xmatched it. - SQL fix: a to-many relationship through a to-one one
(owner.roles.type) joined its relationship table to the main table
(user__roles__rel.role = store.id), not to the to-one's
(user__roles__rel.user = user.id): it matched the wrong rows. - SQL fix: a
DELETEthrough a relationship (to-one,deleteByQuery( 'owner.email == ?'), or to-many) was invalid SQL (DELETE ... JOIN): its
JOINs are now in the subquery of the IDs too (MySQL: in a derived
table, as aDELETEcan't select from its own table). - SQL fix: a number or a decimal
Stringcompared with aDecimalfield
(roles.value == "1.5") was resolved asnull(IS NULL). - Memory: a to-many relationship is compared one related entity at a time
(as a SQL join of its rows), and one without related entities as one row
ofnulls (as a SQL outer join):roles.type == nullandroles.type =~ [null]match a user without
roles, androles.type != nulland!~ [null]don't (they did).
!= "admin"and!~ ["admin"]still match it.roles.type == ?with a list parameter ([['guest']],[[null]])
compares each related entity's value with it, as a field's
number == ?does (it matched nothing).- Only a to-many relationship (
KeyCondition.hasToManyInKeyPath, by the
declared field types): an empty list field (List<String>,
Uint8List) is still a value, not anull.
- Memory fix:
deleteByQuerythrough a to-many relationship, of a table
without to-one references (address:stores.name == ?), deleted
nothing (its relationships weren't resolved, as a select does). - Memory: a
Decimalfield compares by value:value == 1.5,
value =~ [1.5, 3]andvalue == ?with aDecimalmatched nothing (an
entity's map keeps it as aString;EntityHandler.equalsValues*now
compare aDynamicNumberwith a number or a plain decimalStringby
value).
Known differences (SQL):
-
2 conditions over the same to-many relationship
(roles.type == "admin" && roles.type == "guest") are, in memory, each
any related entity, and on SQL the same joined row (so this matches
nothing on SQL). Prefer one condition (roles.type =~ [...]), or!(...)
(a subquery each). -
2 to-many relationships to the same table in one query
(address.storesandaddress.closedStores, both tostore) share one
JOIN:stores.name == "a" && closedStores.name == "b"compares both
with the same row. -
A path that reaches the main table again (
store:owner.address.stores .name) has a duplicated table alias: an error on SQL. -
Tests: 'Operators: the same results on every adapter', on all the DB
adapters: ~240 conditions, each also checked through!(...)(its
complement), as a sorted list (an entity selected twice fails), and
x == null/x != nullchecked to split the entities.==,!=,
=~,!~,>,>=,<,<=,!,&&,||and groups; a literal, a
single value, a list,null,[null], a list with anull,[], a
regexp (/.../,/.../i), and the parameters?,?:name,/?/and
/?:name/(alsonull,[]and a list with==). Over text, a nullable
number, a date, an enum, a bool, a nullable decimal (also as aString),
a nullable to-one relationship (by its ID, a field of it,
owner.address.city2 relationships away), a to-many one (roles, also
a user without any), and a to-many through a to-one (owner.roles). And
countByQuery,limit/offset, anddeleteByQuerythrough a to-one
and a to-many relationship.