Coverage for databases/sync_tests/arrays/test_bigint.py: 100%
35 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 prisma import Prisma
4def test_updating_bigints(client: Prisma) -> None:
5 """Updating a BigInt[] value"""
6 models = [
7 client.lists.create({}),
8 client.lists.create(
9 data={
10 'bigints': [539506179039297536, 281454500584095754],
11 },
12 ),
13 ]
15 model = client.lists.update(
16 where={
17 'id': models[1].id,
18 },
19 data={
20 'bigints': {
21 'set': [129003276736659456],
22 },
23 },
24 )
25 assert model is not None
26 assert model.bigints == [129003276736659456]
28 model = client.lists.update(
29 where={
30 'id': models[1].id,
31 },
32 data={
33 'bigints': [298490675715112960],
34 },
35 )
36 assert model is not None
37 assert model.bigints == [298490675715112960]
40def test_filtering_bigints(client: Prisma) -> None:
41 """Searching for records by a BigInt[] value"""
42 with client.batch_() as batcher:
43 batcher.lists.create({})
44 batcher.lists.create(
45 data={
46 'bigints': [],
47 },
48 )
49 batcher.lists.create(
50 data={
51 'bigints': [1, 2, 3],
52 },
53 )
55 model = client.lists.find_first(
56 where={
57 'bigints': {
58 'equals': None,
59 },
60 },
61 )
62 assert model is not None
63 assert model.bigints == []
65 model = client.lists.find_first(
66 where={
67 'bigints': {
68 'equals': [1, 2, 3],
69 },
70 },
71 )
72 assert model is not None
73 assert model.bigints == [1, 2, 3]
75 model = client.lists.find_first(
76 where={
77 'bigints': {
78 'has': 1,
79 },
80 },
81 )
82 assert model is not None
83 assert model.bigints == [1, 2, 3]
85 model = client.lists.find_first(
86 where={
87 'bigints': {
88 'has': 4,
89 },
90 },
91 )
92 assert model is None
94 model = client.lists.find_first(
95 where={
96 'bigints': {
97 'has_some': [2, 3, 4],
98 },
99 },
100 )
101 assert model is not None
102 assert model.bigints == [1, 2, 3]
104 model = client.lists.find_first(
105 where={
106 'bigints': {
107 'has_every': [2, 3, 4],
108 },
109 },
110 )
111 assert model is None
113 model = client.lists.find_first(
114 where={
115 'bigints': {
116 'has_every': [1, 2],
117 },
118 },
119 )
120 assert model is not None
121 assert model.bigints == [1, 2, 3]
123 count = client.lists.count(
124 where={
125 'bigints': {
126 'is_empty': True,
127 },
128 },
129 )
130 assert count == 1