mirror of
https://github.com/sqlalchemy/sqlalchemy.git
synced 2026-05-27 02:52:53 -04:00
Use regexp to parse cx_oracle version string
Fixed bug in cx_Oracle dialect where version string parsing would fail for cx_Oracle version 6.0b1 due to the "b" character. Version string parsing is now via a regexp rather than a simple split. Change-Id: I2af7172b0d7184e3ea3bd051e9fa8d6ca2a571cd Fixes: #3975 (cherry picked from commit 50484eda7787c3e83c9c88c1841fc63b348ca23c)
This commit is contained in:
Vendored
+9
@@ -21,6 +21,15 @@
|
||||
.. changelog::
|
||||
:version: 1.1.10
|
||||
|
||||
.. change:: 3975
|
||||
:tags: bug, oracle
|
||||
:versions: 1.2.0b1
|
||||
:tickets: 3975
|
||||
|
||||
Fixed bug in cx_Oracle dialect where version string parsing would
|
||||
fail for cx_Oracle version 6.0b1 due to the "b" character. Version
|
||||
string parsing is now via a regexp rather than a simple split.
|
||||
|
||||
.. change:: 3980
|
||||
:tags: bug, ext
|
||||
:versions: 1.2.0b1
|
||||
|
||||
@@ -706,8 +706,8 @@ class OracleDialect_cx_oracle(OracleDialect):
|
||||
self._retry_on_12516 = _retry_on_12516
|
||||
|
||||
if hasattr(self.dbapi, 'version'):
|
||||
self.cx_oracle_ver = tuple([int(x) for x in
|
||||
self.dbapi.version.split('.')])
|
||||
self.cx_oracle_ver = self._parse_cx_oracle_ver(self.dbapi.version)
|
||||
|
||||
else:
|
||||
self.cx_oracle_ver = (0, 0, 0)
|
||||
|
||||
@@ -773,6 +773,16 @@ class OracleDialect_cx_oracle(OracleDialect):
|
||||
self.dbapi.BINARY: oracle.RAW(),
|
||||
}
|
||||
|
||||
def _parse_cx_oracle_ver(self, version):
|
||||
m = re.match(r'(\d+)\.(\d+)(?:\.(\d+))?', version)
|
||||
if m:
|
||||
return tuple(
|
||||
int(x)
|
||||
for x in m.group(1, 2, 3)
|
||||
if x is not None)
|
||||
else:
|
||||
return (0, 0, 0)
|
||||
|
||||
@classmethod
|
||||
def dbapi(cls):
|
||||
import cx_Oracle
|
||||
|
||||
@@ -24,6 +24,26 @@ from sqlalchemy import sql
|
||||
from sqlalchemy.testing.mock import Mock
|
||||
|
||||
|
||||
class DialectTest(fixtures.TestBase):
|
||||
def test_cx_oracle_version_parse(self):
|
||||
dialect = cx_oracle.OracleDialect_cx_oracle()
|
||||
|
||||
eq_(
|
||||
dialect._parse_cx_oracle_ver("5.2"),
|
||||
(5, 2)
|
||||
)
|
||||
|
||||
eq_(
|
||||
dialect._parse_cx_oracle_ver("5.0.1"),
|
||||
(5, 0, 1)
|
||||
)
|
||||
|
||||
eq_(
|
||||
dialect._parse_cx_oracle_ver("6.0b1"),
|
||||
(6, 0)
|
||||
)
|
||||
|
||||
|
||||
class OutParamTest(fixtures.TestBase, AssertsExecutionResults):
|
||||
__only_on__ = 'oracle+cx_oracle'
|
||||
__backend__ = True
|
||||
@@ -2260,3 +2280,4 @@ class ServiceNameTest(fixtures.TestBase):
|
||||
create_engine, url_string,
|
||||
_initialize=False
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user