Use the connection attribute ``max_identifier_length`` available
in oracledb since version 2.5 when determining the identifier length
in the Oracle dialect.
Fixes: #12032
Change-Id: If16db93e0df25776295bc521706dbad1cc541f4a
(cherry picked from commit
90bf575b81c5396b364908547551b6592a333bf7)
--- /dev/null
+.. change::
+ :tags: oracle, usecase
+ :tickets: 12032
+
+ Use the connection attribute ``max_identifier_length`` available
+ in oracledb since version 2.5 when determining the identifier length
+ in the Oracle dialect.
actual server version in order to assist with migration of Oracle databases,
and may be configured within the Oracle server itself. This compatibility
version is retrieved using the query ``SELECT value FROM v$parameter WHERE
-name = 'compatible';``. The SQLAlchemy Oracle dialect, when tasked with
-determining the default max identifier length, will attempt to use this query
-upon first connect in order to determine the effective compatibility version of
-the server, which determines what the maximum allowed identifier length is for
-the server. If the table is not available, the server version information is
-used instead.
+name = 'compatible';``.
+The SQLAlchemy Oracle dialect, when tasked with determining the default max
+identifier length, will use the ``max_identifier_length`` attribute available
+in the connection of the oracledb driver since version 2.5. When using an older
+version or cx_oracle SQLAlchemy will instead attempted to use the query
+mentioned above upon first connect in order to determine the effective
+compatibility version of the server, which determines what the maximum allowed
+identifier length is for the server. If the table is not available, the server
+version information is used instead.
As of SQLAlchemy 1.4, the default max identifier length for the Oracle dialect
is 128 characters. Upon first connect, the compatibility version is detected
for fi, gti, bq in connection.connection.tpc_recover()
]
+ def _check_max_identifier_length(self, connection):
+ if self.oracledb_ver >= (2, 5):
+ return connection.connection.max_identifier_length
+ else:
+ super()._check_max_identifier_length(connection)
+
class AsyncAdapt_oracledb_cursor(AsyncAdapt_dbapi_cursor):
_cursor: AsyncCursor
self._adapt_connection._handle_exception(error)
async def _execute_async(self, operation, parameters):
- # override to not use mutex, oracledb already has mutex
+ # override to not use mutex, oracledb already has a mutex
if parameters is None:
result = await self._cursor.execute(operation)
operation,
seq_of_parameters,
):
- # override to not use mutex, oracledb already has mutex
+ # override to not use mutex, oracledb already has a mutex
return await self._cursor.executemany(operation, seq_of_parameters)
def __enter__(self):
def stmtcachesize(self, value):
self._connection.stmtcachesize = value
+ @property
+ def max_identifier_length(self):
+ return self._connection.max_identifier_length
+
def cursor(self):
return AsyncAdapt_oracledb_cursor(self)