sqlalchemy-iris 0.17.1b8__py3-none-any.whl → 0.17.2b1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sqlalchemy_iris/base.py +57 -8
- {sqlalchemy_iris-0.17.1b8.dist-info → sqlalchemy_iris-0.17.2b1.dist-info}/METADATA +1 -1
- {sqlalchemy_iris-0.17.1b8.dist-info → sqlalchemy_iris-0.17.2b1.dist-info}/RECORD +7 -7
- {sqlalchemy_iris-0.17.1b8.dist-info → sqlalchemy_iris-0.17.2b1.dist-info}/WHEEL +0 -0
- {sqlalchemy_iris-0.17.1b8.dist-info → sqlalchemy_iris-0.17.2b1.dist-info}/entry_points.txt +0 -0
- {sqlalchemy_iris-0.17.1b8.dist-info → sqlalchemy_iris-0.17.2b1.dist-info}/licenses/LICENSE +0 -0
- {sqlalchemy_iris-0.17.1b8.dist-info → sqlalchemy_iris-0.17.2b1.dist-info}/top_level.txt +0 -0
sqlalchemy_iris/base.py
CHANGED
@@ -408,10 +408,21 @@ class IRISCompiler(sql.compiler.SQLCompiler):
|
|
408
408
|
return "EXISTS(%s)" % self.process(element.element, **kw)
|
409
409
|
|
410
410
|
def limit_clause(self, select, **kw):
|
411
|
-
|
411
|
+
# handle the limit and offset clauses
|
412
|
+
if select._has_row_limiting_clause and not self._use_top(select):
|
413
|
+
limit_clause = self._get_limit_or_fetch(select)
|
414
|
+
offset_clause = select._offset_clause
|
412
415
|
|
413
|
-
|
414
|
-
|
416
|
+
if limit_clause is not None:
|
417
|
+
if offset_clause is not None:
|
418
|
+
return " LIMIT %s OFFSET %s" % (
|
419
|
+
self.process(limit_clause, **kw),
|
420
|
+
self.process(offset_clause, **kw),
|
421
|
+
)
|
422
|
+
else:
|
423
|
+
return " LIMIT %s" % self.process(limit_clause, **kw)
|
424
|
+
else:
|
425
|
+
return ""
|
415
426
|
|
416
427
|
def visit_empty_set_expr(self, type_, **kw):
|
417
428
|
return "SELECT 1 WHERE 1!=1"
|
@@ -541,16 +552,39 @@ class IRISCompiler(sql.compiler.SQLCompiler):
|
|
541
552
|
if not (select._has_row_limiting_clause and not self._use_top(select)):
|
542
553
|
return select
|
543
554
|
|
544
|
-
|
545
|
-
|
555
|
+
# check the current version of the iris server
|
556
|
+
server_version = self.dialect.server_version_info
|
546
557
|
|
547
|
-
|
558
|
+
if server_version is None or server_version < (2025, 1):
|
559
|
+
return self._handle_legacy_pagination(select, select_stmt)
|
560
|
+
else:
|
561
|
+
return self._handle_modern_pagination(select, select_stmt)
|
562
|
+
|
563
|
+
def _get_default_order_by(self, select_stmt, select):
|
564
|
+
"""Get default ORDER BY clauses when none are specified."""
|
548
565
|
_order_by_clauses = [
|
549
566
|
sql_util.unwrap_label_reference(elem)
|
550
567
|
for elem in select._order_by_clause.clauses
|
551
568
|
]
|
569
|
+
|
552
570
|
if not _order_by_clauses:
|
553
|
-
|
571
|
+
# If no ORDER BY clause, use the primary key
|
572
|
+
if select_stmt.froms and isinstance(select_stmt.froms[0], schema.Table):
|
573
|
+
table = select.froms[0]
|
574
|
+
if table.primary_key and table.primary_key.columns:
|
575
|
+
_order_by_clauses = [
|
576
|
+
sql_util.unwrap_label_reference(c)
|
577
|
+
for c in table.primary_key.columns
|
578
|
+
]
|
579
|
+
else:
|
580
|
+
# If no primary key, use the id column
|
581
|
+
_order_by_clauses = [text("%id")]
|
582
|
+
|
583
|
+
return _order_by_clauses
|
584
|
+
|
585
|
+
def _handle_legacy_pagination(self, select, select_stmt):
|
586
|
+
"""Handle pagination for IRIS versions before 2025.1 using ROW_NUMBER()."""
|
587
|
+
_order_by_clauses = self._get_default_order_by(select_stmt, select)
|
554
588
|
|
555
589
|
limit_clause = self._get_limit_or_fetch(select)
|
556
590
|
offset_clause = select._offset_clause
|
@@ -566,6 +600,7 @@ class IRISCompiler(sql.compiler.SQLCompiler):
|
|
566
600
|
|
567
601
|
iris_rn = sql.column(label)
|
568
602
|
limitselect = sql.select(*[c for c in select.c if c.key != label])
|
603
|
+
|
569
604
|
if offset_clause is not None:
|
570
605
|
if limit_clause is not None:
|
571
606
|
limitselect = limitselect.where(
|
@@ -574,9 +609,23 @@ class IRISCompiler(sql.compiler.SQLCompiler):
|
|
574
609
|
else:
|
575
610
|
limitselect = limitselect.where(iris_rn > offset_clause)
|
576
611
|
else:
|
577
|
-
limitselect = limitselect.where(iris_rn <=
|
612
|
+
limitselect = limitselect.where(iris_rn <= limit_clause)
|
613
|
+
|
578
614
|
return limitselect
|
579
615
|
|
616
|
+
def _handle_modern_pagination(self, select, select_stmt):
|
617
|
+
"""Handle pagination for IRIS 2025.1+ using native LIMIT/OFFSET."""
|
618
|
+
_order_by_clauses = self._get_default_order_by(select_stmt, select)
|
619
|
+
|
620
|
+
new_select = select._generate().order_by(*_order_by_clauses)
|
621
|
+
|
622
|
+
# Apply limit if present
|
623
|
+
if select._limit_clause is not None:
|
624
|
+
new_select = new_select.limit(select._limit_clause)
|
625
|
+
|
626
|
+
return new_select
|
627
|
+
|
628
|
+
|
580
629
|
def order_by_clause(self, select, **kw):
|
581
630
|
order_by = self.process(select._order_by_clause, **kw)
|
582
631
|
|
@@ -65,7 +65,7 @@ irisnative/_IRISNative.py,sha256=HQ4nBhc8t8_5OtxdMG-kx1aa-T1znf2I8obZOPLOPzg,665
|
|
65
65
|
irisnative/__init__.py,sha256=6YmvBLQSURsCPKaNg7LK-xpo4ipDjrlhKuwdfdNb3Kg,341
|
66
66
|
sqlalchemy_iris/__init__.py,sha256=79niafYbL1XOw3eJfu0KwrHfP8CIb2I4HdN4B9PI_sQ,1297
|
67
67
|
sqlalchemy_iris/alembic.py,sha256=L58qBIj6HwLmtU6FS5RXKW0gHr1mNTrBSChEllSh1n0,6607
|
68
|
-
sqlalchemy_iris/base.py,sha256=
|
68
|
+
sqlalchemy_iris/base.py,sha256=30Qn-bbCqze5BQKr_W_GYjAmrolIYJ538QtAqcR3FVA,56654
|
69
69
|
sqlalchemy_iris/embedded.py,sha256=5WZ78PIYB_pPyaLrK4E7kHUsGBRiwzYHjsTDiNYHUGg,819
|
70
70
|
sqlalchemy_iris/information_schema.py,sha256=FUL3z_viGjjOvDA71Mbk5k94dUGcLV4dW1xHxBgM1rk,6188
|
71
71
|
sqlalchemy_iris/iris.py,sha256=Of0Ruc9W2c5ll5sjAy1xRo4tf1m0l_ab0vAdacTv3Yw,276
|
@@ -75,9 +75,9 @@ sqlalchemy_iris/requirements.py,sha256=9Klyec0qS2MHEaXbONauP7FUF5bi__vfsBrwOEKKT
|
|
75
75
|
sqlalchemy_iris/types.py,sha256=M5uyeANVN6MU40kiWBePGTCnVaAAKmfLOHq7zuJ0z6A,12024
|
76
76
|
sqlalchemy_iris/intersystems/__init__.py,sha256=J1WcKKAfEASHTmxCav_sGQeb2GE-FXgrgWnUDY8zMag,5463
|
77
77
|
sqlalchemy_iris/intersystems/dbapi.py,sha256=JOPjpXrD_cwCzAwnO9cRwBtv2SM8YbczOk8PFX3oM_4,899
|
78
|
-
sqlalchemy_iris-0.17.
|
79
|
-
sqlalchemy_iris-0.17.
|
80
|
-
sqlalchemy_iris-0.17.
|
81
|
-
sqlalchemy_iris-0.17.
|
82
|
-
sqlalchemy_iris-0.17.
|
83
|
-
sqlalchemy_iris-0.17.
|
78
|
+
sqlalchemy_iris-0.17.2b1.dist-info/licenses/LICENSE,sha256=RQmigqltsLq8lfOBc_KwtL0gkODyUCNpU-0ZiZwGlho,1075
|
79
|
+
sqlalchemy_iris-0.17.2b1.dist-info/METADATA,sha256=Vyd-lYMaHD1urTk6AoDDKhNHzZhQDIk-aGQfrOsSX_Y,4195
|
80
|
+
sqlalchemy_iris-0.17.2b1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
81
|
+
sqlalchemy_iris-0.17.2b1.dist-info/entry_points.txt,sha256=sYU1YvyyeGqOVVMpHySThfEhrVQL1lUVz5rDwmwCj7E,258
|
82
|
+
sqlalchemy_iris-0.17.2b1.dist-info/top_level.txt,sha256=QRY18YUXUJrRde4aayj_brj0lr2LBRVZS1ZoVoDFVS0,45
|
83
|
+
sqlalchemy_iris-0.17.2b1.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|