-
-
Notifications
You must be signed in to change notification settings - Fork 502
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
Typecasting in postgres does not work for jsonb query with operators #1734
Comments
I believe this should be fixed in 4.5.4, so please try that version. |
Amazing. Thank you so much for your awesome work and the quick response! Nevertheless, the next problem arose:
However, the above query does the comparison string-wise, yielding the following error:
So MikroORM is casting the lat and lng values as strings via the jsonb query. How can I solve this? |
Weird, casting is handled in postgres, are you really sure that the type is number? There is a I guess it might be caused by the usage of operators, can you try strict comparison just to verify that? |
No, it's how the query is translated. |
I know how it works, and as I said it is implemented. Afaik I asked you to verify that it is caused by the operators you are using, so please try whether this produces the type cast: return this.em.find(Location, {
locationGeometry: {
bounds: {
northeast: { lat: coords.lat },
southwest: { lat: coords.lat },
},
},
locationType: {
$in: locationTypes,
},
}); |
Your query translates to this sql query which works:
So it seems like it's caused by the use of the $gte and $lte operators. |
Ooops, wrong issue number, this is not fixed. Will look into it tomorrow. In the mean time you could try using sql fragment: https://mikro-orm.io/docs/entity-manager/#using-custom-sql-fragments |
there were some NPM issues, so its actually |
Describe the bug
PostgreSQL CamelCase to snail_case conversion does not work for jsonb query.
Stack trace
Field is called locationGeometry in the Entity but location_geometry in the databse.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Should translate the camelCase column name to snake_case.
Additional context
Will be provided if necessary.
Versions
Using NestJS and Postgres 13.
"@mikro-orm/cli": "^4.5.3",
"@mikro-orm/core": "^4.5.3",
"@mikro-orm/nestjs": "^4.2.0",
"@mikro-orm/postgresql": "^4.5.3",
"@mikro-orm/reflection": "^4.5.3",
The text was updated successfully, but these errors were encountered: