MCPcopy
hub / github.com/django/django / test_rawsql_annotation

Method test_rawsql_annotation

tests/queries/test_query.py:165–174  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

163
164class TestQueryNoModel(TestCase):
165 def test_rawsql_annotation(self):
166 query = Query(None)
167 sql = "%s = 1"
168 # Wrap with a CASE WHEN expression if a database backend (e.g. Oracle)
169 # doesn't support boolean expression in SELECT list.
170 if not connection.features.supports_boolean_expr_in_select_clause:
171 sql = f"CASE WHEN {sql} THEN 1 ELSE 0 END"
172 query.add_annotation(RawSQL(sql, (1,), BooleanField()), "_check")
173 result = query.get_compiler(using=DEFAULT_DB_ALIAS).execute_sql(SINGLE)
174 self.assertEqual(result[0], 1)
175
176 def test_subquery_annotation(self):
177 query = Query(None)

Callers

nothing calls this directly

Calls 6

add_annotationMethod · 0.95
get_compilerMethod · 0.95
QueryClass · 0.90
RawSQLClass · 0.90
BooleanFieldClass · 0.90
execute_sqlMethod · 0.45

Tested by

no test coverage detected