From: Sergio Oller Moreno Date: Tue, 2 Jul 2024 08:39:00 +0000 (-0400) Subject: Fix table reflection on oracle <10.2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f9a865c3d4ebb35ab072cd7d39b654fe927cbb3a;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Fix table reflection on oracle <10.2 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 --- diff --git a/doc/build/changelog/unreleased_20/11557.txt b/doc/build/changelog/unreleased_20/11557.txt new file mode 100644 index 0000000000..be270a6f25 --- /dev/null +++ b/doc/build/changelog/unreleased_20/11557.txt @@ -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. diff --git a/lib/sqlalchemy/dialects/oracle/base.py b/lib/sqlalchemy/dialects/oracle/base.py index 4f180cbd9e..5e0ff64883 100644 --- a/lib/sqlalchemy/dialects/oracle/base.py +++ b/lib/sqlalchemy/dialects/oracle/base.py @@ -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(