From: Mike Bayer Date: Fri, 12 Mar 2010 23:45:53 +0000 (+0000) Subject: further refinement X-Git-Tag: rel_0_6beta2~54^2~18 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0744264be82d13b48538a5efd210251ec340205b;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git further refinement --- 0744264be82d13b48538a5efd210251ec340205b diff --cc lib/sqlalchemy/dialects/oracle/cx_oracle.py index b9f567d344,75e6cadf51..ab92cc4663 --- a/lib/sqlalchemy/dialects/oracle/cx_oracle.py +++ b/lib/sqlalchemy/dialects/oracle/cx_oracle.py @@@ -329,35 -341,36 +329,37 @@@ class Oracle_cx_oracle(OracleDialect) self.auto_setinputsizes = auto_setinputsizes self.auto_convert_lobs = auto_convert_lobs -- def vers(num): -- return tuple([int(x) for x in num.split('.')]) -- if hasattr(self.dbapi, 'version'): -- cx_oracle_ver = vers(self.dbapi.version) ++ cx_oracle_ver = tuple([int(x) for x in self.dbapi.version.split('.')]) self.supports_unicode_binds = cx_oracle_ver >= (5, 0) self._cx_oracle_native_nvarchar = cx_oracle_ver >= (5, 0) - - if self.dbapi is not None and not hasattr(self.dbapi, 'UNICODE'): - # cx_Oracle WITH_UNICODE mode. *only* python - # unicode objects accepted for anything - self._cx_oracle_string_types = set([self.dbapi.STRING, self.dbapi.NCLOB]) - self.supports_unicode_statements = True - self.supports_unicode_binds = True - self._cx_oracle_with_unicode = True - else: - cx_oracle_ver = None ++ else: ++ cx_oracle_ver = None + ++ def types(*names): ++ return set([getattr(self.dbapi, name, None) for name in names]).difference([None]) ++ ++ self._cx_oracle_string_types = types("STRING", "UNICODE", "NCLOB", "CLOB") ++ self._cx_oracle_unicode_types = types("UNICODE", "NCLOB") ++ self._cx_oracle_binary_types = types("BFILE", "CLOB", "NCLOB", "BLOB") ++ + if cx_oracle_ver is None: + # this occurs in tests with mock DBAPIs + self._cx_oracle_string_types = set() + self._cx_oracle_with_unicode = False + elif not hasattr(self.dbapi, 'UNICODE'): + # cx_Oracle WITH_UNICODE mode. *only* python + # unicode objects accepted for anything - self._cx_oracle_string_types = set([self.dbapi.STRING]) + self.supports_unicode_statements = True + self.supports_unicode_binds = True + self._cx_oracle_with_unicode = True else: - self._cx_oracle_with_unicode = False - if self.dbapi is not None: - self._cx_oracle_string_types = set([self.dbapi.UNICODE, self.dbapi.NCLOB, self.dbapi.STRING]) - self._cx_oracle_unicode_types = set([self.dbapi.UNICODE, self.dbapi.NCLOB]) - else: - self._cx_oracle_string_types = set() - - - if self.dbapi is None or \ + self._cx_oracle_with_unicode = False - self._cx_oracle_string_types = set([self.dbapi.UNICODE, self.dbapi.STRING]) - - if self.dbapi is None or \ ++ ++ if cx_oracle_ver is None or \ not self.auto_convert_lobs or \ not hasattr(self.dbapi, 'CLOB'): self.dbapi_type_map = {} -- self._cx_oracle_binary_types = set() else: # only use this for LOB objects. using it for strings, dates # etc. leads to a little too much magic, reflection doesn't know if it should @@@ -368,9 -381,9 +370,6 @@@ self.dbapi.BLOB: oracle.BLOB(), self.dbapi.BINARY: oracle.RAW(), } -- self._cx_oracle_binary_types = set([getattr(self.dbapi, k) for k in -- ["BFILE", "CLOB", "NCLOB", "BLOB"] -- if hasattr(self.dbapi, k)]) @classmethod def dbapi(cls):