-
Notifications
You must be signed in to change notification settings - Fork 181
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
eq object (JSON columns) doesn't work #477
Comments
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I'm not gonna fight with stale-bot ... having something like that activate without the maintainers even visibly acknowledging the issue just encourages switching to a better supported framework :( |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Hi @mgabeler-lee-6rs, apologies for not attending to the issue earlier. I've added this to my pipeline for review and will try to see if I can timebox this. Currently, there's quite a bit of backlog at my end so unfortunately I may not be able to work on a fix asap; Though I'm open to merging community contributions. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Steps to reproduce
find
searching for a full value in that property/column, e.g.const objectValue = {a: 1, b: 2};
and thenrepo.find({where: {objectProperty: objectValue}})
orrepo.find({where: {objectProperty: {eq: objectValue}}})
Current Behavior
{objectProperty: {eq: value}}
is translated down into{objectProperty: value}
a
as an operator namebuildExpression
operator switch hits itsdefault
clause which delegates to the base class inloopback-connector
: https://github.com/strongloop/loopback-connector-postgresql/blob/master/lib/postgresql.js#L540-L543switch
with nodefault
clause, so it doesn't throw any errors and just concatenates the column name with the placeholder for the value: https://github.com/strongloop/loopback-connector/blob/master/lib/sql.js#L969"columName"$1
Expected Behavior
Link to reproduction sandbox
WIP -- NB: encountering this in an LB4 app
Additional information
linux x64 12.22.1
npm ls
doesn't work withrush
, but usingloopback-connector-postgresql
v5.0.1, withloopback-connector
v4.11.1, and the following LB4 components:"@loopback/boot": "2.2.0"
"@loopback/context": "3.9.3"
"@loopback/core": "2.5.0"
"@loopback/metadata": "2.2.6"
"@loopback/openapi-v3": "3.3.1"
"@loopback/openapi-v3-types": "1.2.1"
"@loopback/repository": "2.4.0"
"@loopback/rest": "4.0.0"
"@loopback/rest-explorer": "2.2.0"
Related Issues
Haven't found any yet
Workaround
Create a custom class to represent the value, and then have the equality comparison value use that, e.g. something like this, but without the prototype pollution vulnerabilities:
This causes the
expression.constructor === Object
check to fail, and so it doesn't try to unwrap the valueThe text was updated successfully, but these errors were encountered: