summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/build/changelog/changelog_08.rst9
-rw-r--r--lib/sqlalchemy/dialects/oracle/base.py4
-rw-r--r--test/dialect/test_oracle.py6
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)