ORM entity values
As an improvement to writing find conditions, we could have a sugar syntax specifically for EntityInteface
objects. What if the following:
$query = $memberships->find()->where(['user_id' => $user, 'organization_id' => $org]);
Would generate a query like:
SELECT * FROM memberships WHERE user_id = 141231 AND organization_id = 523423
All query parameter values for 'entities' would be resolved via id
(if set), or by using the table's primary key configuration. We could make this work with composite primary keys reasonably easy as well. Preferring id
allows the conventions to be fast, and custom work to be accommodated but with a performance penalty.
Only values containing EntityInterface
would be resolved like this. All other values would not be dereferenced and instead would be passed onto the type caster for the column.
We would still require using the column id, and not the association name, as resolving association names is non-trivial as you have to check all keys alongside their aliases. I also dislike association name resolution as it obfuscates the query that the ORM will actually perform.