diff options
author | Florian Apolloner <florian@apolloner.eu> | 2022-12-02 10:43:49 +0100 |
---|---|---|
committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-12-02 10:56:09 +0100 |
commit | 3e3b7f691b5cc41c357966ce3f91a8d13c6c1d4d (patch) | |
tree | b2e65415859d0e43ed82867ed4b0cd17a5cd99bb /tests/queries | |
parent | 2fecf99ade208e3a80958ee4fc28ff62549c575b (diff) | |
download | django-3e3b7f691b5cc41c357966ce3f91a8d13c6c1d4d.tar.gz |
Refs #33308 -- Avoided passing None to RawSQL's params.
Passing None to params causes errors in determining the data type on
psycopg3.
Diffstat (limited to 'tests/queries')
-rw-r--r-- | tests/queries/test_query.py | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/tests/queries/test_query.py b/tests/queries/test_query.py index b0a5058f6c..99d0e32427 100644 --- a/tests/queries/test_query.py +++ b/tests/queries/test_query.py @@ -164,12 +164,12 @@ class TestQuery(SimpleTestCase): class TestQueryNoModel(TestCase): def test_rawsql_annotation(self): query = Query(None) - sql = "%s IS NULL" + sql = "%s = 1" # Wrap with a CASE WHEN expression if a database backend (e.g. Oracle) # doesn't support boolean expression in SELECT list. if not connection.features.supports_boolean_expr_in_select_clause: sql = f"CASE WHEN {sql} THEN 1 ELSE 0 END" - query.add_annotation(RawSQL(sql, (None,), BooleanField()), "_check") + query.add_annotation(RawSQL(sql, (1,), BooleanField()), "_check") result = query.get_compiler(using=DEFAULT_DB_ALIAS).execute_sql(SINGLE) self.assertEqual(result[0], 1) @@ -183,8 +183,7 @@ class TestQueryNoModel(TestCase): def test_q_annotation(self): query = Query(None) check = ExpressionWrapper( - Q(RawSQL("%s IS NULL", (None,), BooleanField())) - | Q(Exists(Item.objects.all())), + Q(RawSQL("%s = 1", (1,), BooleanField())) | Q(Exists(Item.objects.all())), BooleanField(), ) query.add_annotation(check, "_check") |