#19726: Ordering on booleans works different with SQLite and Postgres
-------------------------------------+-------------------------------------
     Reporter:  anonymous            |                    Owner:  nobody
         Type:                       |                   Status:  new
  Cleanup/optimization               |
    Component:  Database layer       |                  Version:  dev
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by bcail):

 >>In Postgres, the true comes first
 I've been looking at this issue, and there's something weird. When I sort
 by a boolean field in postgres, I see false values first (postgresql 13):
 {{{
 playground=# \d stock_availability;
            Table "public.stock_availability"
    Column   |  Type   | Collation | Nullable | Default
 ------------+---------+-----------+----------+---------
  product_id | integer |           | not null |
  available  | boolean |           | not null |
 Indexes:
     "stock_availability_pkey" PRIMARY KEY, btree (product_id)

 playground=# select * from stock_availability;
  product_id | available
 ------------+-----------
         100 | t
         200 | f
         300 | t
         400 | t
         500 | t
         600 | t
         700 | f
         800 | f

 playground=# select * from stock_availability order by available;
  product_id | available
 ------------+-----------
         200 | f
         700 | f
         800 | f
         100 | t
         600 | t
         500 | t
         300 | t
         400 | t
 }}}

 What am I missing?

-- 
Ticket URL: <https://code.djangoproject.com/ticket/19726#comment:7>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070183aecd28a3-199a2e1c-a1b1-48ea-82c8-8f0264aa479c-000000%40eu-central-1.amazonses.com.

Reply via email to