def schemadropper(self, proxy, **params):
raise NotImplementedError()
+ def compiler(self, statement, bindparams):
+ raise NotImplementedError()
+
+ def create(self, table, **params):
+ table.accept_visitor(self.schemagenerator(self.proxy(), **params))
+
+ def drop(self, table, **params):
+ table.accept_visitor(self.schemadropper(self.proxy(), **params))
+
+ def compile(self, statement, bindparams):
+ compiler = self.compiler(statement, bindparams)
+ statement.accept_visitor(compiler)
+ return compiler
+
def reflecttable(self, table):
raise NotImplementedError()
def dbapi(self):
raise NotImplementedError()
- def compile(self, statement, bindparams):
- raise NotImplementedError()
-
def do_begin(self, connection):
"""implementations might want to put logic here for turning autocommit on/off, etc."""
pass
def subquery(alias, *args, **params):
return Alias(Select(*args, **params), alias)
-def bindparam(key, value = None):
- return BindParamClause(key, value)
+def bindparam(key, value = None, type=None):
+ return BindParamClause(key, value, type=type)
def text(text):
return TextClause(text)
params = [self.get_params(**m) for m in multiparams]
else:
params = self.get_params(**params)
- return self.engine.execute(str(self), params, compiled = self)
+ return self.engine.execute(str(self), params, compiled = self, typemap = self.typemap)
class ClauseElement(object):
"""base class for elements of a programmatically constructed SQL expression.
self.key = key
self.value = value
self.shortname = shortname
- self.type = type
+ self.type = type or types.NULLTYPE
def accept_visitor(self, visitor):
visitor.visit_bindparam(self)
return "BindParam(%s, %s, %s)" % (repr(self.key), repr(self.value), repr(self.shortname))
def typeprocess(self, value):
- if self.type is not None:
- return self.type.convert_bind_param(value)
- else:
- return value
+ return self.type.convert_bind_param(value)
class TextClause(ClauseElement):
"""represents any plain text WHERE clause or full SQL statement"""
else:
col = key
try:
- parameters[key] = bindparam(col.name, value)
+ parameters[key] = bindparam(col.name, value, type=col.type)
except KeyError:
del parameters[key]
return parameters
# case one: no parameters in the statement, no parameters in the
# compiled params - just return binds for all the table columns
if parameters is None and self.parameters is None:
- return [(c, bindparam(c.name)) for c in self.table.columns]
+ return [(c, bindparam(c.name, type=c.type)) for c in self.table.columns]
# if we have statement parameters - set defaults in the
# compiled params
if d.has_key(c):
value = d[c]
if _is_literal(value):
- value = bindparam(c.name, value)
+ value = bindparam(c.name, value, type=c.type)
values.append((c, value))
return values