#36494: Various failures in JSONField lookups when using expressions in 
right-hand
side
-------------------------------------+-------------------------------------
     Reporter:  Jacob Walls          |                    Owner:  Jacob
         Type:                       |  Walls
  Cleanup/optimization               |                   Status:  assigned
    Component:  Database layer       |                  Version:  dev
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  1
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Clifford Gama):

 * needs_better_patch:  0 => 1

Comment:

 There's a PostgreSQL failure to look at:
 {{{#!python
 ======================================================================
 ERROR: test_numeric_lookup_with_expression
 (model_fields.test_jsonfield.TestQuerying.test_numeric_lookup_with_expression)
 ----------------------------------------------------------------------
 Traceback (most recent call last):
   File "/home/clifford/code/django/django/db/backends/utils.py", line 105,
 in _execute
     return self.cursor.execute(sql, params)
            ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
   File "/home/clifford/.pyenv/versions/dj/lib/python3.14/site-
 packages/psycopg/cursor.py", line 117, in execute
     raise ex.with_traceback(None)
 psycopg.errors.UndefinedFunction: operator does not exist: jsonb > integer
 LINE 1: ...("model_fields_nullablejsonmodel"."value" -> 'c') > 999 LIMI...
                                                              ^
 HINT:  No operator matches the given name and argument types. You might
 need to add explicit type casts.

 The above exception was the direct cause of the following exception:

 Traceback (most recent call last):
   File "/home/clifford/code/django/tests/model_fields/test_jsonfield.py",
 line 1299, in test_numeric_lookup_with_expression
     self.assertIs(qs_val.exists(), False)
                   ~~~~~~~~~~~~~^^
   File "/home/clifford/code/django/django/db/models/query.py", line 1409,
 in exists
     return self.query.has_results(using=self.db)
            ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
   File "/home/clifford/code/django/django/db/models/sql/query.py", line
 681, in has_results
     return compiler.has_results()
            ~~~~~~~~~~~~~~~~~~~~^^
   File "/home/clifford/code/django/django/db/models/sql/compiler.py", line
 1599, in has_results
     return bool(self.execute_sql(SINGLE))
                 ~~~~~~~~~~~~~~~~^^^^^^^^
   File "/home/clifford/code/django/django/db/models/sql/compiler.py", line
 1631, in execute_sql
     cursor.execute(sql, params)
     ~~~~~~~~~~~~~~^^^^^^^^^^^^^
   File "/home/clifford/code/django/django/db/backends/utils.py", line 79,
 in execute
     return self._execute_with_wrappers(
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~^
         sql, params, many=False, executor=self._execute
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     )
     ^
   File "/home/clifford/code/django/django/db/backends/utils.py", line 92,
 in _execute_with_wrappers
     return executor(sql, params, many, context)
   File "/home/clifford/code/django/django/db/backends/utils.py", line 100,
 in _execute
     with self.db.wrap_database_errors:
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   File "/home/clifford/code/django/django/db/utils.py", line 94, in
 __exit__
     raise dj_exc_value.with_traceback(traceback) from exc_value
   File "/home/clifford/code/django/django/db/backends/utils.py", line 105,
 in _execute
     return self.cursor.execute(sql, params)
            ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
   File "/home/clifford/.pyenv/versions/dj/lib/python3.14/site-
 packages/psycopg/cursor.py", line 117, in execute
     raise ex.with_traceback(None)
 django.db.utils.ProgrammingError: operator does not exist: jsonb > integer
 LINE 1: ...("model_fields_nullablejsonmodel"."value" -> 'c') > 999 LIMI...
                                                              ^
 HINT:  No operator matches the given name and argument types. You might
 need to add explicit type casts.

 ----------------------------------------------------------------------
 Ran 81 tests in 0.768s

 FAILED (errors=1, skipped=4)
 }}}
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36494#comment:6>
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 visit 
https://groups.google.com/d/msgid/django-updates/0107019ccd84f144-b1e28546-5950-496a-8fb2-97bd838993a7-000000%40eu-central-1.amazonses.com.

Reply via email to