You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Embeddable arrays cannot be searched in mysql (haven't tested other drivers). I think the mysql driver manually creates a query for searching json objects but doesn't take into account that embeddables can be arrays of objects.
To Reproduce
Create an Embeddable array property in an entity:
This will produce an sql query looking something like this:
select `e0`.* from `player` as `e0`
where `e0`.`props`->'$.value' like '%xyz%'
Expected behavior
If the embeddable is set to array mode then the query should use the json array search syntax. I'm not sure if there's any fancy syntax for doing that but currently I'm using the QueryBuilder to manually use json_extract:
em.createQueryBuilder(Player, 'p')
.where('json_extract(props, \'$[*].value\') like ?', [`%${search}%`])
The text was updated successfully, but these errors were encountered:
tudddorrr
changed the title
Embeddable array of objects cannot be search by properties
Embeddable array of objects cannot be searched by properties
Jun 6, 2021
The problem with this is that only MySQL offers feasible solution, I haven't found a way to do it with other drivers (that would fit how the QB is designed).
More context here, I got some suggestions on how this could be done, but the problem is that it's not possible to go that way without a lot of added abstractions, or it would be very limited in general.
Describe the bug
Embeddable arrays cannot be searched in mysql (haven't tested other drivers). I think the mysql driver manually creates a query for searching json objects but doesn't take into account that embeddables can be arrays of objects.
To Reproduce
Create an Embeddable array property in an entity:
Try to search by a property inside the array of objects:
This will produce an sql query looking something like this:
Expected behavior
If the embeddable is set to array mode then the query should use the json array search syntax. I'm not sure if there's any fancy syntax for doing that but currently I'm using the QueryBuilder to manually use
json_extract
:The text was updated successfully, but these errors were encountered: