ORDER BY a json field fails in CTE select_from
See original GitHub issueclass Foo(Model):
data = BinaryJSONField()
# OK: Produces SELECT ... ORDER BY ("foo"."data"->>'x');
Foo.select().order_by(Foo.data['x'])
# NOK: Produces WITH foos AS (...) SELECT ... ORDER BY ("foos"."data" = 'x');
cte = Foo.select().cte('foos')
query = cte.select_from().order_by(cte.c.data['x'])
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
sql - How to get the second highest to lowest value record on ...
Here I have a JSON field I want to ...
Read more >Working with CTEs (Common Table Expressions)
A CTE (common table expression) is a named subquery defined in a WITH clause. ... The CTE defines the temporary view's name, an...
Read more >Solve common issues with JSON in SQL Server
I want to create a JSON text result from a simple SQL query on a single ... FOR JSON queries as column expressions...
Read more >Common Table Expressions (WITH Queries) - Cockroach Labs
A common table expression (CTE), also called a WITH query, ... In this example, the inner subquery SELECT * FROM v will select...
Read more >16.20 - Examples: SELECT AS JSON - Teradata Database
Following is the table definition for these examples. CREATE TABLE MyTable ( a INTEGER, b INTEGER, j JSON AUTO COLUMN); These statements ...
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 FreeTop 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
Top GitHub Comments
Ouch…that’s going to be rather difficult to fix, unfortunately, perhaps not possible. I’d suggest in the meantime trying something like:
Good suggestions, thank you.