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
NOTE: This is a bug in loopback-datasource-juggler, however the issue template there explicitly requests filing bugs in this project so 🤷
loopbackio/loopback-datasource-juggler#1662 brought in some validation code that only is applicable to MongoDB, and is making certain operation on JSON properties/columns with SQL databases excessively difficult.
It is already impossible to do json equality searches out of the box due to #477, however that issue has a fairly straight forward workaround.
That workaround fails if the JSON object you are searching for contains any properties starting with a $ at the top level however, because they are interpreted as extended operators, even if they cannot possibly actually be such.
For example, pretend #477 was already fixed and you wrote this where expression:
{where: {propertyName: {eq: {$foo: 'bar'}}}}
The $foo, AFAICT, cannot possibly be an operator because you already specified the eq operator.
Furthermore, if you're not using MongoDB, then this whole thing is moot anyways and these checks are inapplicable.
Steps to reproduce
Create an entity type with a property of object type mapped to a SQL field of json type
Insert a record that has a key in this property, at the top level, whose name starts with a $
Attempt to do a find() call to locate this record using an equality match on that property
NOTE: This is a bug in
loopback-datasource-juggler
, however the issue template there explicitly requests filing bugs in this project so 🤷loopbackio/loopback-datasource-juggler#1662 brought in some validation code that only is applicable to MongoDB, and is making certain operation on JSON properties/columns with SQL databases excessively difficult.
It is already impossible to do json equality searches out of the box due to #477, however that issue has a fairly straight forward workaround.
That workaround fails if the JSON object you are searching for contains any properties starting with a
$
at the top level however, because they are interpreted as extended operators, even if they cannot possibly actually be such.For example, pretend #477 was already fixed and you wrote this where expression:
The
$foo
, AFAICT, cannot possibly be an operator because you already specified theeq
operator.Furthermore, if you're not using MongoDB, then this whole thing is moot anyways and these checks are inapplicable.
Steps to reproduce
$
find()
call to locate this record using an equality match on that propertyCurrent Behavior
OPERATOR_NOT_ALLOWED_IN_QUERY
error and refuses to run your queryExpected Behavior
Loopback should be able to do
property = ?
queries on JSON fields against SQL databases.Link to reproduction sandbox
WIP
Additional information
Same environment as #477
Related Issues
The text was updated successfully, but these errors were encountered: