-
Notifications
You must be signed in to change notification settings - Fork 235
Description
Lithium Version: 1.0
$data = MyModel::all([
'fields' => [
'IFNULL(prices->\'$."1"\', prices->\'$."default"\') as MyModel.price',
],
])->data();
I'm trying to access a value of a json field in my field list (returns many results and processing serverside isn't very feasible because of speed concerns). I'm getting an error in /data/source/Database.php on line 680. It appears to be splitting all the field name values on '.' in order to sort them?
I have also tried 'MyModel.price' => 'IFNULL(prices->\'$."1"\', prices->\'$."default"\')'
and received the same result.
To my knowledge there is no way to retrieve data from a JSON field within a query without specifying a path, which requires using the '$.field' notation. Is there a way for me to mark this as a calculated field and prevent this from happening? Alternately is there an official way to access JSON fields with li3, or to disable this "sorting" from occurring?