Coverage for databases/sync_tests/types/raw_queries/arrays/test_bigint.py: 100%
18 statements
« prev ^ index » next coverage.py v7.2.7, created at 2024-08-27 18:25 +0000
« prev ^ index » next coverage.py v7.2.7, created at 2024-08-27 18:25 +0000
1from pydantic import BaseModel
3from prisma import Prisma
4from prisma.models import Lists
6from ....._types import DatabaseMapping, SupportedDatabase
7from ....._compat import LiteralString
10class Queries(BaseModel):
11 select: LiteralString
14_mysql_queries = Queries(
15 select='SELECT * FROM Lists WHERE `id` = ?',
16)
18_postgresql_queries = Queries(
19 select='SELECT * FROM "Lists" WHERE id = $1',
20)
22RAW_QUERIES: DatabaseMapping[Queries] = {
23 'mysql': _mysql_queries,
24 'mariadb': _mysql_queries,
25 'sqlite': Queries(
26 select='SELECT * FROM Lists WHERE id = ?',
27 ),
28 'postgresql': _postgresql_queries,
29 'cockroachdb': _postgresql_queries,
30}
33def test_query_first(
34 client: Prisma,
35 database: SupportedDatabase,
36) -> None:
37 """Standard usage of BigInt[] in raw SELECT queries"""
38 queries = RAW_QUERIES[database]
40 record = client.lists.create({'bigints': [12522]})
42 found = client.query_first(queries.select, record.id)
43 assert found['id'] == record.id
44 assert found['bigints'] == [12522]
46 model = client.query_first(queries.select, record.id, model=Lists)
47 assert model is not None
48 assert model.id == record.id
49 assert model.bigints == [12522]