Opened 6 years ago

Closed 6 years ago

#30336 closed New feature (duplicate)

F() expression wrong result on postgres JSONField

Reported by: blue-note Owned by: armansabyr
Component: contrib.postgres Version: dev
Severity: Normal Keywords: jsonfield, postgres, F
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

On the model

class Product(Model):
    properties = JSONField()

when querying with Product.objects.values('properties__color'), the resulting query is SELECT ("product"."properties" -> 'color') FROM "product"

However, when using the equivalent F() expression product = Product.objects.values(color=F('properties__color'))}} the resulting query is {{{SELECT "product"."properties" AS "color" FROM "product", which ignores part of the field name

Change History (2)

comment:1 by armansabyr, 6 years ago

Owner: changed from nobody to armansabyr
Status: newassigned

comment:2 by Mariusz Felisiak, 6 years ago

Component: Database layer (models, ORM)contrib.postgres
Keywords: F added
Resolution: duplicate
Status: assignedclosed
Type: BugNew feature
Version: 2.2master

Duplicate of #29769.

Note: See TracTickets for help on using tickets.
Back to Top