diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-11-22 17:56:35 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-11-22 17:56:35 -0500 |
commit | 467784e89c0817a74df32db4b12bd8b3e28a05df (patch) | |
tree | 2caf44efac58105c35a2e7954520c356c90684e4 | |
parent | 6661cba88d14ecba88ae905e1852bac3f084966d (diff) | |
download | sqlalchemy-467784e89c0817a74df32db4b12bd8b3e28a05df.tar.gz |
Fixed bug where Oracle ``VARCHAR`` types given with no length
(e.g. for a ``CAST`` or similar) would incorrectly render ``None CHAR``
or similar. [ticket:2870]
-rw-r--r-- | doc/build/changelog/changelog_08.rst | 9 | ||||
-rw-r--r-- | lib/sqlalchemy/dialects/oracle/base.py | 4 | ||||
-rw-r--r-- | test/dialect/test_oracle.py | 6 |
3 files changed, 18 insertions, 1 deletions
diff --git a/doc/build/changelog/changelog_08.rst b/doc/build/changelog/changelog_08.rst index dde98e82f..cc51febe1 100644 --- a/doc/build/changelog/changelog_08.rst +++ b/doc/build/changelog/changelog_08.rst @@ -12,6 +12,15 @@ :version: 0.8.4 .. change:: + :tags: bug, oracle + :tickets: 2870 + :versions: 0.9.0b2 + + Fixed bug where Oracle ``VARCHAR`` types given with no length + (e.g. for a ``CAST`` or similar) would incorrectly render ``None CHAR`` + or similar. + + .. change:: :tags: bug, ext :tickets: 2869 :versions: 0.9.0b2 diff --git a/lib/sqlalchemy/dialects/oracle/base.py b/lib/sqlalchemy/dialects/oracle/base.py index 1f5e05cba..e7263ba52 100644 --- a/lib/sqlalchemy/dialects/oracle/base.py +++ b/lib/sqlalchemy/dialects/oracle/base.py @@ -398,7 +398,9 @@ class OracleTypeCompiler(compiler.GenericTypeCompiler): return self._visit_varchar(type_, '', '') def _visit_varchar(self, type_, n, num): - if not n and self.dialect._supports_char_length: + if not type_.length: + return "%(n)sVARCHAR%(two)s" % {'two': num, 'n': n} + elif not n and self.dialect._supports_char_length: varchar = "VARCHAR%(two)s(%(length)s CHAR)" return varchar % {'length': type_.length, 'two': num} else: diff --git a/test/dialect/test_oracle.py b/test/dialect/test_oracle.py index 36dae9e90..185bfb883 100644 --- a/test/dialect/test_oracle.py +++ b/test/dialect/test_oracle.py @@ -1013,6 +1013,12 @@ class DialectTypesTest(fixtures.TestBase, AssertsCompiledSQL): (VARCHAR(50), "VARCHAR(50 CHAR)"), (oracle.NVARCHAR2(50), "NVARCHAR2(50)"), (oracle.VARCHAR2(50), "VARCHAR2(50 CHAR)"), + (String(), "VARCHAR2"), + (Unicode(), "NVARCHAR2"), + (NVARCHAR(), "NVARCHAR2"), + (VARCHAR(), "VARCHAR"), + (oracle.NVARCHAR2(), "NVARCHAR2"), + (oracle.VARCHAR2(), "VARCHAR2"), ]: self.assert_compile(typ, exp, dialect=dialect) |