Problems withs PostGres 9.3, JSON Field and Query Distinct
See original GitHub issueAs mentionned in #47, using “.distinct()”, which is used by the admin panel creating users but also in several other cases in django processes, triggers the same bug as #47 describes.
A workaround has been found by @mkhattab :
The work around for this in the Django admin is to subclass QuerySet
and Manager
and override the distinct
method [to remove the JSON fields from it].
What would be the definite fix ?
Issue Analytics
- State:
- Created 10 years ago
- Comments:20 (1 by maintainers)
Top Results From Across the Web
Problems withs PostGres 9.3, JSON Field and Query Distinct
I tried running the OrderedDictSerializationTest class which came in the out-of-the-box tests.py for 0.9.20. I'm using Postgres 9.3.2 and Django 1.5. The class ......
Read more >Is it possible to select distinct values in a json document using ...
Assuming a JSON array in a Postgres 9.4 jsonb column, this would do the job: SELECT DISTINCT ON (doc->'s') doc FROM ( SELECT...
Read more >Distinct on Postgresql JSON data column - Stack Overflow
The reason behind this, is that in PostgreSQL (up to 9.3) there is no equality operator defined for json (i.e. val1::json = val2::json...
Read more >9.4: JSON Functions and Operators - PostgreSQL
Many of these operators can be indexed by jsonb operator classes. ... This form of json_object takes keys and values pairwise from two...
Read more >Select distinct values by key from JSONB column-postgresql
how to get data from jsonb column in postgres? · PostgreSQL - How to convert current timestamp into bytea · PostgreSQL & DataMapper...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Solved my case.
Hope, this helps to somebody
I had this issue popping up in Admin list views for models that contained JSON columns (even though I wasn’t showing those field in the view). Interestingly enough, when the view is called, it doesn’t actually call the
distinct
method on theManager
. My workaround was to subclass the manager, and override theget_query_set
method as follows: