@@ -409,6 +409,8 @@ def visit_exists_unary_operator(
409
409
410
410
def limit_clause (self , select , ** kw ):
411
411
# handle the limit and offset clauses
412
+ if not self .dialect .supports_modern_pagination :
413
+ return ""
412
414
if select ._has_row_limiting_clause and not self ._use_top (select ):
413
415
limit_clause = self ._get_limit_or_fetch (select )
414
416
offset_clause = select ._offset_clause
@@ -424,6 +426,11 @@ def limit_clause(self, select, **kw):
424
426
else :
425
427
return ""
426
428
429
+ def fetch_clause (self , select , ** kw ):
430
+ if not self .dialect .supports_modern_pagination :
431
+ return ""
432
+ return super ().fetch_clause (select , ** kw )
433
+
427
434
def visit_empty_set_expr (self , type_ , ** kw ):
428
435
return "SELECT 1 WHERE 1!=1"
429
436
@@ -493,7 +500,7 @@ def get_select_precolumns(self, select, **kw):
493
500
else :
494
501
text += "DISTINCT "
495
502
496
- if select ._has_row_limiting_clause and self ._use_top (select ):
503
+ if not self . dialect . supports_modern_pagination and select ._has_row_limiting_clause and self ._use_top (select ):
497
504
text += "TOP %s " % self .process (self ._get_limit_or_fetch (select ), ** kw )
498
505
499
506
return text
@@ -552,13 +559,10 @@ def translate_select_structure(self, select_stmt, **kwargs):
552
559
if not (select ._has_row_limiting_clause and not self ._use_top (select )):
553
560
return select
554
561
555
- # check the current version of the iris server
556
- server_version = self .dialect .server_version_info
557
-
558
- if server_version is None or server_version < (2025 , 1 ):
559
- return self ._handle_legacy_pagination (select , select_stmt )
560
- else :
562
+ if self .dialect .supports_modern_pagination :
561
563
return self ._handle_modern_pagination (select , select_stmt )
564
+ else :
565
+ return self ._handle_legacy_pagination (select , select_stmt )
562
566
563
567
def _get_default_order_by (self , select_stmt , select ):
564
568
"""Get default ORDER BY clauses when none are specified."""
@@ -625,7 +629,6 @@ def _handle_modern_pagination(self, select, select_stmt):
625
629
626
630
return new_select
627
631
628
-
629
632
def order_by_clause (self , select , ** kw ):
630
633
order_by = self .process (select ._order_by_clause , ** kw )
631
634
@@ -884,6 +887,14 @@ def create_cursor(self):
884
887
cursor = self ._dbapi_connection .cursor ()
885
888
return cursor
886
889
890
+ @util .non_memoized_property
891
+ def rowcount (self ) -> int :
892
+ print ("_rowcount" , self ._rowcount , self .cursor ._closed , self .cursor .rowcount )
893
+ if self ._rowcount is not None :
894
+ return self ._rowcount
895
+ else :
896
+ return self .cursor .rowcount
897
+
887
898
888
899
colspecs = {
889
900
sqltypes .Boolean : IRISBoolean ,
@@ -959,6 +970,8 @@ class IRISDialect(default.DefaultDialect):
959
970
update_executemany_returning = False
960
971
delete_executemany_returning = False
961
972
973
+ supports_modern_pagination = False
974
+
962
975
construct_arguments = [
963
976
(schema .Index , {"include" : None }),
964
977
]
@@ -986,6 +999,10 @@ def _get_server_version_info(self, connection):
986
999
def _get_default_schema_name (self , connection ):
987
1000
return IRISDialect .default_schema_name
988
1001
1002
+ def initialize (self , connection ):
1003
+ super ().initialize (connection )
1004
+ self .supports_modern_pagination = self .server_version_info >= (2025 , 1 )
1005
+
989
1006
def on_connect (self ):
990
1007
super_ = super ().on_connect ()
991
1008
0 commit comments