MCPcopy Index your code
hub / github.com/tortoise/tortoise-orm / test_exists

Function test_exists

tests/test_sql.py:152–166  ·  view source on GitHub ↗
(sql_context)

Source from the content-addressed store, hash-verified

150
151
152def test_exists(sql_context):
153 db, dialect, is_psycopg = sql_context
154 sql = IntFields.filter(intnum=1).exists().sql()
155 if dialect == "mysql":
156 expected = "SELECT 1 FROM `intfields` WHERE `intnum`=%s LIMIT %s"
157 elif dialect == "postgres":
158 if is_psycopg:
159 expected = 'SELECT 1 FROM "intfields" WHERE "intnum"=%s LIMIT %s'
160 else:
161 expected = 'SELECT 1 FROM "intfields" WHERE "intnum"=$1 LIMIT $2'
162 elif dialect == "mssql":
163 expected = 'SELECT 1 FROM "intfields" WHERE "intnum"=? ORDER BY (SELECT 0) OFFSET 0 ROWS FETCH NEXT ? ROWS ONLY'
164 else:
165 expected = 'SELECT 1 FROM "intfields" WHERE "intnum"=? LIMIT ?'
166 assert sql == expected
167
168
169def test_count(sql_context):

Callers

nothing calls this directly

Calls 3

sqlMethod · 0.45
existsMethod · 0.45
filterMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…