-
-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support relations via array
type columns
#362
Labels
type:feature
New feature
Comments
What's the support in other DBs? |
|
If it's MySQL and PostgreSQL then it is worth doing. |
This was referenced Jun 29, 2024
Merged
Done with #375 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently AR supports
scalar
toarray
relations:$this->hasMany(Item::class, ['id' => 'item_ids'])
where
id
isinteger
columnand
item_ids
isinteger array
columnBut AR does not support
array
toscalar
relations$this->hasMany(Promotion::class, ['item_ids' => 'id'])
The reason is in preparing the query condition. Currently it is only
IN
conditionactive-record/src/ActiveRelationTrait.php
Line 636 in b000730
Which will generate condition like
id IN (1, 2, 3)
But for
array
column this should be arrays overlap condition likeitem_ids && ARRAY[1, 2, 3]
(Postgres)To solve the issue it requires:
ArrayOverlapCondition
andJsonOverlapCondition
(for json arrays) in db packagesAR::columnType($columnName)
method to get type of the columnThe text was updated successfully, but these errors were encountered: