Skip to content

Commit a3766f9

Browse files
authored
fix: Fix failed to execute _column_query (#46)
* fix: update OceanBase version handling in cx_oracle.py to prevent misidentification and ensure compatibility with NVARCHAR2 queries * BugFix: Fixed decorator usage in cx_oracle.py for constraint data retrieval.
1 parent 8ec119b commit a3766f9

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

oceanbase-sqlalchemy-plugin/oceanbase_sqlalchemy/cx_oracle.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,18 @@ def _get_server_version_info(self, connection):
6060
"""
6161
Get OceanBase server version information
6262
63-
Issue: cx_Oceanbase driver returns "0.0.0.0.1" for connection.version,
63+
Issue1: cx_Oceanbase driver returns "0.0.0.0.1" for connection.version,
6464
causing SQLAlchemy to misidentify it as Oracle 8 and set supports_unicode_binds to False,
6565
which encodes all string parameters as bytes, resulting in NVARCHAR2 query failures.
6666
67-
Solution: Extract the real OceanBase version number from v$version banner.
67+
Issue2: Hard-code a pre-12c version so SQLAlchemy will not try to query
68+
Oracle-only dictionary views such as ALL_TAB_IDENTITY_COLS, which
69+
OceanBase does not implement. Unicode bind support is forced on in
70+
initialize(), so we do not rely on the reported version for that.
71+
_column_query() in base.py will fail with ORA-00942: table or view does not exist.
6872
"""
6973

70-
# Fallback: Return a reasonable default version
71-
# Note: Due to Python tuple comparison (4, x, x) < (9,) evaluates to True
72-
# Use (21, 0, 0, 0, 0) to simulate Oracle 21g, ensuring it won't be misidentified as Oracle 8
73-
return (21, 0, 0, 0, 0)
74+
return (11, 2, 0, 0)
7475

7576
def initialize(self, connection):
7677
"""

oceanbase-sqlalchemy-plugin/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setup(
77
name="oceanbase-sqlalchemy",
8-
version="0.5.1",
8+
version="0.6.0",
99
description="SQLAlchemy dialect for OceanBase Oracle mode (supports SQLAlchemy 1.3.x and 2.0+)",
1010
long_description=open("README.md", "r", encoding="utf-8").read(),
1111
long_description_content_type="text/markdown",

0 commit comments

Comments
 (0)