3
3
from sqlalchemy .testing .suite import CTETest as _CTETest
4
4
from sqlalchemy .testing .suite import DifficultParametersTest as _DifficultParametersTest
5
5
from sqlalchemy .testing import fixtures
6
+ from sqlalchemy .orm import Session
6
7
from sqlalchemy import testing
7
8
from sqlalchemy import Table , Column , Integer , String , select
8
9
import pytest
@@ -28,7 +29,6 @@ class DifficultParametersTest(_DifficultParametersTest):
28
29
29
30
30
31
class FetchLimitOffsetTest (_FetchLimitOffsetTest ):
31
-
32
32
def test_simple_offset_no_order (self , connection ):
33
33
table = self .tables .some_table
34
34
self ._assert_result (
@@ -55,37 +55,14 @@ def test_simple_limit_offset_no_order(self, connection, cases):
55
55
assert_data = [(1 , 1 , 2 ), (2 , 2 , 3 ), (3 , 3 , 4 ), (4 , 4 , 5 ), (5 , 4 , 6 )]
56
56
57
57
for limit , offset in cases :
58
- expected = assert_data [offset : offset + limit ]
58
+ expected = assert_data [offset : offset + limit ]
59
59
self ._assert_result (
60
60
connection ,
61
61
select (table ).limit (limit ).offset (offset ),
62
62
expected ,
63
63
)
64
64
65
65
66
- # class MiscTest(AssertsExecutionResults, AssertsCompiledSQL, fixtures.TablesTest):
67
-
68
- # __backend__ = True
69
-
70
- # __only_on__ = "iris"
71
-
72
- # @classmethod
73
- # def define_tables(cls, metadata):
74
- # Table(
75
- # "some_table",
76
- # metadata,
77
- # Column("id", Integer, primary_key=True),
78
- # Column("x", Integer),
79
- # Column("y", Integer),
80
- # Column("z", String(50)),
81
- # )
82
-
83
- # # def test_compile(self):
84
- # # table = self.tables.some_table
85
-
86
- # # stmt = select(table.c.id, table.c.x).offset(20).limit(10)
87
-
88
-
89
66
class TransactionTest (fixtures .TablesTest ):
90
67
__backend__ = True
91
68
@@ -134,3 +111,42 @@ def test_rollback(self, local_connection):
134
111
transaction .rollback ()
135
112
result = connection .exec_driver_sql ("select * from users" )
136
113
assert len (result .fetchall ()) == 0
114
+
115
+
116
+ class IRISExistsTest (fixtures .TablesTest ):
117
+ __backend__ = True
118
+
119
+ @classmethod
120
+ def define_tables (cls , metadata ):
121
+ Table (
122
+ "users" ,
123
+ metadata ,
124
+ Column ("user_id" , Integer , primary_key = True ),
125
+ Column ("user_name" , String (20 )),
126
+ test_needs_acid = True ,
127
+ )
128
+
129
+ @classmethod
130
+ def insert_data (cls , connection ):
131
+ connection .execute (
132
+ cls .tables .users .insert (),
133
+ [
134
+ {"user_id" : 1 , "user_name" : "admin" },
135
+ ],
136
+ )
137
+
138
+ def test_exists (self ):
139
+ with config .db .connect () as conn :
140
+ with Session (conn ) as s :
141
+ assert s .query (
142
+ select (self .tables .users )
143
+ .where (self .tables .users .c .user_name == "admin" )
144
+ .exists ()
145
+ ).scalar ()
146
+
147
+ assert not s .query (
148
+ select (self .tables .users )
149
+ .where (self .tables .users .c .user_name == "nope" )
150
+ .exists ()
151
+ ).scalar ()
152
+
0 commit comments