From de103379d3e345f6d21d6e97403caefe30d9b152 Mon Sep 17 00:00:00 2001 From: yuanoOo Date: Tue, 10 Feb 2026 14:35:05 +0800 Subject: [PATCH 1/2] fix: handle index expressions compatibility for SQLAlchemy 2.x Added a check for the presence of index expressions in the dictionary module to ensure compatibility with SQLAlchemy 2.x. This change modifies the behavior of the _index_query method in the OceanBaseDialect_cx_oracle class based on the availability of index expressions. --- .../oceanbase_sqlalchemy/cx_oracle.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/oceanbase-sqlalchemy-plugin/oceanbase_sqlalchemy/cx_oracle.py b/oceanbase-sqlalchemy-plugin/oceanbase_sqlalchemy/cx_oracle.py index 3be9e408..69846ed8 100644 --- a/oceanbase-sqlalchemy-plugin/oceanbase_sqlalchemy/cx_oracle.py +++ b/oceanbase-sqlalchemy-plugin/oceanbase_sqlalchemy/cx_oracle.py @@ -22,6 +22,12 @@ if SA_20_PLUS: from sqlalchemy.dialects.oracle import dictionary + _dictionary_has_ind_expressions = ( + getattr(dictionary, "all_ind_expressions", None) is not None + ) +else: + _dictionary_has_ind_expressions = False + class OceanBaseCompiler_cx_oracle(OracleCompiler_cx_oracle): """ @@ -239,6 +245,8 @@ def _index_query(self, owner): Only for sqlalchemy 2.x compatibility. """ + if not _dictionary_has_ind_expressions: + return super()._index_query(owner) return ( select( dictionary.all_ind_columns.c.table_name, From c223e45f5b9c82a1d155f59060d8b7be135fb577 Mon Sep 17 00:00:00 2001 From: yuanoOo Date: Tue, 10 Feb 2026 14:54:01 +0800 Subject: [PATCH 2/2] remove cx_oracle --- oceanbase-sqlalchemy-plugin/setup.py | 1 - 1 file changed, 1 deletion(-) diff --git a/oceanbase-sqlalchemy-plugin/setup.py b/oceanbase-sqlalchemy-plugin/setup.py index e92d8bc4..6750071d 100644 --- a/oceanbase-sqlalchemy-plugin/setup.py +++ b/oceanbase-sqlalchemy-plugin/setup.py @@ -18,7 +18,6 @@ keywords="sqlalchemy oceanbase oracle dialect database", install_requires=[ "sqlalchemy>=1.3.0", - "cx_oracle>=8.0.0", ], entry_points={ "sqlalchemy.dialects": [