Sometimes it is useful to unequivocally refer to the key-side of a foreign-key. This mostly comes up with @NotFound mappings, where we generally join and use the target-side of the foreign-key.
Given a not-found mapping Coin#currency (from the testsuite), a query like from Coin c where c.currency.id = 1 will result in a SQL query with a join and the predicate based on the Currency’s id column.
But it is sometimes useful to be able to refer explicitly to the foreign-key key-side. To allow for this, add a fk(...) “function” to SQM
Sometimes it is useful to unequivocally refer to the key-side of a foreign-key. This mostly comes up with
@NotFound
mappings, where we generally join and use the target-side of the foreign-key.Given a not-found mapping
Coin#currency
(from the testsuite), a query likefrom Coin c where c.currency.id = 1
will result in a SQL query with a join and the predicate based on the Currency’s id column.But it is sometimes useful to be able to refer explicitly to the foreign-key key-side. To allow for this, add a
fk(...)
“function” to SQME.g.
from Coin c where fk(c.currency) = 1