Skip to content
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

Properties with type: 'json' do not use their fieldName(s) value #1673

Closed
bravely opened this issue Apr 13, 2021 · 1 comment
Closed

Properties with type: 'json' do not use their fieldName(s) value #1673

bravely opened this issue Apr 13, 2021 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@bravely
Copy link

bravely commented Apr 13, 2021

Describe the bug
The title really says it all.

Some extra detail, to aid in fixing:

  • This line is where the key for the given field is modified to apply JSON-lookup syntax.

Stack trace
This is misleading, just demonstrates what happens. The entity below has two @Propertys, one of which is dataHash(a string type), and the other as internalData(a JSON type).

error: select "e0".* from "datapoints" as "e0" where "e0"."data_hash" = 'lol' and "internalData"->>'title' = NULL - column "internalData" does not exist

      at Parser.parseErrorMessage (node_modules/pg-protocol/src/parser.ts:357:11)
      at Parser.handlePacket (node_modules/pg-protocol/src/parser.ts:186:21)
      at Parser.parse (node_modules/pg-protocol/src/parser.ts:101:30)
      at Socket.stream.on (node_modules/pg-protocol/src/index.ts:7:48)

To Reproduce
Steps to reproduce the behavior:

  1. Create an entity in a Postgres-backed Mikro-ORM project with a JSON property and a different property name than the column it points at. Easiest way to do this is: @Property({type: 'json'}) aField: Record<string, any> = {}
  2. Insert some data into that field in the DB.
  3. Run a query, any query(where, select, sort, etc) on a property in that field. I have an example above.

Expected behavior
The query to target the appropriate column.

Additional context
None

Versions

Dependency Version
node 10
typescript 4.2
mikro-orm 4.4.4
pg 8.3.2
@bravely
Copy link
Author

bravely commented Apr 13, 2021

Also as a sidenote, it's possible this is also causing the bug for why JSON-queries that filter for null come out as = null instead of is null(as the former will always return empty).

@B4nan B4nan added the bug Something isn't working label Apr 18, 2021
@B4nan B4nan closed this as completed in 73108b1 Apr 18, 2021
B4nan added a commit that referenced this issue Apr 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants