]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Fix table reflection on oracle <10.2
authorSergio Oller Moreno <sergio.ollermoreno@almirall.com>
Tue, 2 Jul 2024 08:39:00 +0000 (04:39 -0400)
committerFederico Caselli <cfederico87@gmail.com>
Tue, 2 Jul 2024 20:11:41 +0000 (22:11 +0200)
Fixed table reflection on Oracle 10.2 and older where compression options
are not supported.

Fixes: #11557
Closes: #11558
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/11558
Pull-request-sha: 44e4f51a3616388f39b0f5edee3124d389765da3

Change-Id: I34c6a367bef158a0c6cf01f185e18392552b7cc7

doc/build/changelog/unreleased_20/11557.txt [new file with mode: 0644]
lib/sqlalchemy/dialects/oracle/base.py

diff --git a/doc/build/changelog/unreleased_20/11557.txt b/doc/build/changelog/unreleased_20/11557.txt
new file mode 100644 (file)
index 0000000..be270a6
--- /dev/null
@@ -0,0 +1,6 @@
+.. change::
+    :tags: bug, reflection, oracle
+    :tickets: 11557
+
+    Fixed table reflection on Oracle 10.2 and older where compression options
+    are not supported.
index 4f180cbd9e74f5974becbe521d5dffaff876b348..5e0ff6488338fe8a826e663ec2ff1993e4f59b16 100644 (file)
@@ -2051,8 +2051,16 @@ class OracleDialect(default.DefaultDialect):
     ):
         query = select(
             dictionary.all_tables.c.table_name,
-            dictionary.all_tables.c.compression,
-            dictionary.all_tables.c.compress_for,
+            (
+                dictionary.all_tables.c.compression
+                if self._supports_table_compression
+                else sql.null().label("compression")
+            ),
+            (
+                dictionary.all_tables.c.compress_for
+                if self._supports_table_compress_for
+                else sql.null().label("compress_for")
+            ),
         ).where(dictionary.all_tables.c.owner == owner)
         if has_filter_names:
             query = query.where(