cases where an explicit CAST might be needed.
[ticket:1879]
- Fixed "default schema" query to work with
pymssql backend.
+- oracle
+ - Added ROWID type to the Oracle dialect, for those
+ cases where an explicit CAST might be needed.
+ [ticket:1879]
+
- examples
- The beaker_caching example has been reorgnized
such that the Session, cache manager,
'VARCHAR', 'NVARCHAR', 'CHAR', 'DATE', 'DATETIME', 'NUMBER',
'BLOB', 'BFILE', 'CLOB', 'NCLOB', 'TIMESTAMP', 'RAW',
'FLOAT', 'DOUBLE_PRECISION', 'LONG', 'dialect', 'INTERVAL',
-'VARCHAR2', 'NVARCHAR2'
+'VARCHAR2', 'NVARCHAR2', 'ROWID'
)
@property
def _type_affinity(self):
return sqltypes.Interval
+
+class ROWID(sqltypes.TypeEngine):
+ """Oracle ROWID type.
+
+ When used in a cast() or similar, generates ROWID.
+
+ """
+ __visit_name__ = 'ROWID'
+
+
class _OracleBoolean(sqltypes.Boolean):
def get_dbapi_type(self, dbapi):
def visit_RAW(self, type_):
return "RAW(%(length)s)" % {'length' : type_.length}
+ def visit_ROWID(self, type_):
+ return "ROWID"
+
class OracleCompiler(compiler.SQLCompiler):
"""Oracle compiler modifies the lexical structure of Select
statements to work under non-ANSI configured Oracle databases, if
class _OracleRaw(oracle.RAW):
pass
+class _OracleRowid(oracle.ROWID):
+ def get_dbapi_type(self, dbapi):
+ return dbapi.ROWID
+
class OracleCompiler_cx_oracle(OracleCompiler):
def bindparam_string(self, name):
if self.preparer._bindparam_requires_quotes(name):
oracle.RAW: _OracleRaw,
sqltypes.Unicode: _OracleNVarChar,
sqltypes.NVARCHAR : _OracleNVarChar,
+ oracle.ROWID: _OracleRowid,
}
finally:
t1.drop()
+ @testing.provide_metadata
+ def test_rowid(self):
+ t = Table('t1', metadata,
+ Column('x', Integer)
+ )
+ t.create()
+ t.insert().execute(x=5)
+ s1 = select([t])
+ s2 = select([column('rowid')]).select_from(s1)
+ rowid = s2.scalar()
+
+ # the ROWID type is not really needed here,
+ # as cx_oracle just treats it as a string,
+ # but we want to make sure the ROWID works...
+ rowid_col= column('rowid', oracle.ROWID)
+ s3 = select([t.c.x, rowid_col]).\
+ where(rowid_col == cast(rowid, oracle.ROWID))
+ eq_(s3.select().execute().fetchall(),
+ [(5, rowid)]
+ )
+
@testing.fails_on('+zxjdbc',
'Not yet known how to pass values of the '
'INTERVAL type')