# Oracle does not allow milliseconds in DATE
# Oracle does not support TIME columns
+# only if cx_oracle contains TIMESTAMP
+class OracleTimestamp(sqltypes.DateTime):
+ def get_col_spec(self):
+ return "TIMESTAMP"
+ def get_dbapi_type(self, dialect):
+ return dialect.TIMESTAMP
+
class OracleText(sqltypes.TEXT):
def get_col_spec(self):
return "CLOB"
sqltypes.Binary : OracleBinary,
sqltypes.Boolean : OracleBoolean,
sqltypes.TEXT : OracleText,
+ sqltypes.TIMESTAMP : OracleTimestamp,
sqltypes.CHAR: OracleChar,
}
-
ischema_names = {
'VARCHAR2' : OracleString,
'DATE' : OracleDateTime,
'DATETIME' : OracleDateTime,
'NUMBER' : OracleNumeric,
'BLOB' : OracleBinary,
- 'CLOB' : OracleText
+ 'CLOB' : OracleText,
+ 'TIMESTAMP' : OracleTimestamp
}
constraintSQL = """SELECT
]}
class OracleExecutionContext(default.DefaultExecutionContext):
- pass
-
+ def pre_exec(self, engine, proxy, compiled, parameters):
+ super(OracleExecutionContext).pre_exec(engine, proxy, compiled, parameters)
+ #self.set_input_sizes(proxy(), parameters)
+
class OracleDialect(ansisql.ANSIDialect):
def __init__(self, use_ansi=True, module=None, threaded=True, **kwargs):
self.use_ansi = use_ansi
self.module = cx_Oracle
else:
self.module = module
+ self.supports_timestamp = hasattr(self.module, 'TIMESTAMP' )
ansisql.ANSIDialect.__init__(self, **kwargs)
def dbapi(self):
return self._last_updated_params
def lastrow_has_defaults(self):
return self._lastrow_has_defaults
+ def set_input_sizes(self, cursor, parameters):
+ """given a cursor and ClauseParameters, call the appropriate style of
+ setinputsizes() on the cursor, using DBAPI types from the bind parameter's
+ TypeEngine objects."""
+ if isinstance(parameters, list):
+ plist = parameters
+ else:
+ plist = [parameters]
+ if self.dialect.positional:
+ inputsizes = []
+ for params in plist[0]:
+ for key in params.positional:
+ typeengine = params.binds[key].type
+ inputsizes.append(typeengine.get_dbapi_type(self.dialect.module))
+ cursor.setinputsizes(*inputsizes)
+ else:
+ inputsizes = {}
+ for params in plist[0]:
+ for key in params.keys():
+ typeengine = params.binds[key].type
+ inputsizes[key] = typeengine.get_dbapi_type(self.dialect.module)
+ cursor.setinputsizes(**inputsizes)
+
def _process_defaults(self, engine, proxy, compiled, parameters):
"""INSERT and UPDATE statements, when compiled, may have additional columns added to their
VALUES and SET lists corresponding to column defaults/onupdates that are present on the
from session import Session as create_session
__all__ = ['relation', 'backref', 'eagerload', 'lazyload', 'noload', 'deferred', 'defer', 'undefer',
- 'mapper', 'clear_mappers', 'sql', 'extension', 'class_mapper', 'object_mapper', 'MapperExtension', 'Query',
+ 'mapper', 'clear_mappers', 'sql', 'class_mapper', 'object_mapper', 'MapperExtension', 'Query',
'cascade_mappers', 'polymorphic_union', 'create_session', 'synonym', 'EXT_PASS'
]
new primary mapper."""
del mapper_registry[m.hash_key]
-def extension(ext):
- """returns a MapperOption that will add the given MapperExtension to the
- mapper returned by mapper.options()."""
- return ExtensionOption(ext)
-
def eagerload(name):
"""returns a MapperOption that will convert the property of the given name
into an eager load."""
return x is y
def is_mutable(self):
return False
+ def get_dbapi_type(self, dbapi):
+ """return the corresponding type object from the underlying DBAPI, if any.
+
+ this can be useful for calling setinputsizes(), for example."""
+ return None
class TypeEngine(AbstractType):
def __init__(self, *args, **params):
instance = self.__class__.__new__(self.__class__)
instance.__dict__.update(self.__dict__)
return instance
+ def get_dbapi_type(self, dbapi):
+ return self.impl.get_dbapi_type(dbapi)
class MutableType(object):
"""a mixin that marks a Type as holding a mutable object"""
return value
else:
return value.decode(dialect.encoding)
-
+ def get_dbapi_type(self, dbapi):
+ return dbapi.STRING
+
class Unicode(TypeDecorator):
impl = String
def convert_bind_param(self, value, dialect):
class Integer(TypeEngine):
"""integer datatype"""
- pass
-
+ def get_dbapi_type(self, dbapi):
+ return dbapi.NUMBER
+
class SmallInteger(Integer):
""" smallint datatype """
pass
self.length = length
def adapt(self, impltype):
return impltype(precision=self.precision, length=self.length)
+ def get_dbapi_type(self, dbapi):
+ return dbapi.NUMBER
class Float(Numeric):
def __init__(self, precision = 10):
self.timezone = timezone
def adapt(self, impltype):
return impltype(timezone=self.timezone)
+ def get_dbapi_type(self, dbapi):
+ return dbapi.DATETIME
class Date(TypeEngine):
"""implements a type for datetime.date() objects"""
- pass
+ def get_dbapi_type(self, dbapi):
+ return dbapi.DATETIME
class Time(TypeEngine):
"""implements a type for datetime.time() objects"""
self.timezone = timezone
def adapt(self, impltype):
return impltype(timezone=self.timezone)
+ def get_dbapi_type(self, dbapi):
+ return dbapi.DATETIME
class Binary(TypeEngine):
def __init__(self, length=None):
return value
def adapt(self, impltype):
return impltype(length=self.length)
+ def get_dbapi_type(self, dbapi):
+ return dbapi.BINARY
class PickleType(MutableType, TypeDecorator):
impl = Binary