Mike Bayer avatar Mike Bayer committed 6967c6e

- repaired the oracle.RAW type which did not
generate the correct DDL. [ticket:2220]
Also in 0.6.9.

Comments (0)

Files changed (3)

     can be caught during a connection 
     event.  [ticket:2201]
 
+  - repaired the oracle.RAW type which did not
+    generate the correct DDL.  [ticket:2220]
+    Also in 0.6.9.
+
 -ext
   - Fixed bug in the mutable extension whereby
     if the same type were used twice in one

lib/sqlalchemy/dialects/oracle/base.py

 NO_ARG_FNS = set('UID CURRENT_DATE SYSDATE USER '
                 'CURRENT_TIME CURRENT_TIMESTAMP'.split())
 
-class RAW(sqltypes.LargeBinary):
-    pass
+class RAW(sqltypes._Binary):
+    __visit_name__ = 'RAW'
 OracleRaw = RAW
 
 class NCLOB(sqltypes.Text):
         return self.visit_SMALLINT(type_)
 
     def visit_RAW(self, type_):
-        return "RAW(%(length)s)" % {'length' : type_.length}
+        if type_.length:
+            return "RAW(%(length)s)" % {'length' : type_.length}
+        else:
+            return "RAW"
 
     def visit_ROWID(self, type_):
         return "ROWID"

test/dialect/test_oracle.py

         finally:
             metadata.drop_all()
 
-    def test_reflect_raw(self):
+    def test_reflect_all_types_schema(self):
         types_table = Table('all_types', MetaData(testing.db),
             Column('owner', String(30), primary_key=True),
             Column('type_name', String(30), primary_key=True),
         for row in types_table.select().execute().fetchall():
             [row[k] for k in row.keys()]
 
+    def test_raw_compile(self):
+        self.assert_compile(oracle.RAW(), "RAW")
+        self.assert_compile(oracle.RAW(35), "RAW(35)")
+
+    @testing.provide_metadata
+    def test_raw_roundtrip(self):
+        metadata = self.metadata
+        raw_table = Table('raw', metadata,
+            Column('id', Integer, primary_key=True),
+            Column('data', oracle.RAW(35))
+        )
+        metadata.create_all()
+        testing.db.execute(raw_table.insert(), id=1, data="ABCDEF")
+        eq_(
+            testing.db.execute(raw_table.select()).first(),
+            (1, "ABCDEF")
+        )
+
+    @testing.provide_metadata
     def test_reflect_nvarchar(self):
-        metadata = MetaData(testing.db)
+        metadata = self.metadata
         t = Table('t', metadata,
             Column('data', sqltypes.NVARCHAR(255))
         )
         metadata.create_all()
-        try:
-            m2 = MetaData(testing.db)
-            t2 = Table('t', m2, autoload=True)
-            assert isinstance(t2.c.data.type, sqltypes.NVARCHAR)
+        m2 = MetaData(testing.db)
+        t2 = Table('t', m2, autoload=True)
+        assert isinstance(t2.c.data.type, sqltypes.NVARCHAR)
 
-            if testing.against('oracle+cx_oracle'):
-                # nvarchar returns unicode natively.  cx_oracle
-                # _OracleNVarChar type should be at play here.
-                assert isinstance(
-                    t2.c.data.type.dialect_impl(testing.db.dialect), 
-                    cx_oracle._OracleNVarChar)
+        if testing.against('oracle+cx_oracle'):
+            # nvarchar returns unicode natively.  cx_oracle
+            # _OracleNVarChar type should be at play here.
+            assert isinstance(
+                t2.c.data.type.dialect_impl(testing.db.dialect), 
+                cx_oracle._OracleNVarChar)
 
-            data = u'm’a réveillé.'
-            t2.insert().execute(data=data)
-            res = t2.select().execute().first()['data']
-            eq_(res, data)
-            assert isinstance(res, unicode)
-        finally:
-            metadata.drop_all()
+        data = u'm’a réveillé.'
+        t2.insert().execute(data=data)
+        res = t2.select().execute().first()['data']
+        eq_(res, data)
+        assert isinstance(res, unicode)
 
     def test_char_length(self):
         self.assert_compile(VARCHAR(50),"VARCHAR(50 CHAR)")
             testing.db.execute("DROP TABLE Z_TEST")
 
     @testing.fails_on('+zxjdbc', 'auto_convert_lobs not applicable')
-    def test_raw_lobs(self):
+    def test_lobs_without_convert(self):
         engine = testing_engine(options=dict(auto_convert_lobs=False))
         metadata = MetaData()
         t = Table("z_test", metadata, Column('id', Integer, primary_key=True), 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.