33from sqlalchemy .testing .suite import CTETest as _CTETest
44from sqlalchemy .testing .suite import DifficultParametersTest as _DifficultParametersTest
55from sqlalchemy .testing import fixtures
6+ from sqlalchemy .orm import Session
67from sqlalchemy import testing
78from sqlalchemy import Table , Column , Integer , String , select
89import pytest
@@ -28,7 +29,6 @@ class DifficultParametersTest(_DifficultParametersTest):
2829
2930
3031class FetchLimitOffsetTest (_FetchLimitOffsetTest ):
31-
3232 def test_simple_offset_no_order (self , connection ):
3333 table = self .tables .some_table
3434 self ._assert_result (
@@ -55,37 +55,14 @@ def test_simple_limit_offset_no_order(self, connection, cases):
5555 assert_data = [(1 , 1 , 2 ), (2 , 2 , 3 ), (3 , 3 , 4 ), (4 , 4 , 5 ), (5 , 4 , 6 )]
5656
5757 for limit , offset in cases :
58- expected = assert_data [offset : offset + limit ]
58+ expected = assert_data [offset : offset + limit ]
5959 self ._assert_result (
6060 connection ,
6161 select (table ).limit (limit ).offset (offset ),
6262 expected ,
6363 )
6464
6565
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-
8966class TransactionTest (fixtures .TablesTest ):
9067 __backend__ = True
9168
@@ -134,3 +111,42 @@ def test_rollback(self, local_connection):
134111 transaction .rollback ()
135112 result = connection .exec_driver_sql ("select * from users" )
136113 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