- changed milestone to 0.6.0
user-defined compileable statements ?
Issue #958
resolved
this is kind of a silly idea:
class MyReplaceStatement(expression.CompileableStatement):
def __init__(self, table):
self.table = table
def compile(self, compiler):
keys = compiler.column_keys
compiler.isinsert = True
bindparams = [type_=self.table.c[key](bindparam(key,).type) for key in keys]
return 'REPLACE INTO %s(%s) VALUES (%s)' %
(
self.table.name,
','.join(self.table.c[key](key).name for key in keys),
','.join(compiler.process(b) for b in bindparams))
)
connection.execute(MyReplaceStatement(sometable), foo='bar')
Comments (3)
-
reporter -
reporter - changed status to resolved
an extension for this is present in 0.6, but needs simplification - for that we have
#1331. -
reporter - removed milestone
Removing milestone: 0.6.0 (automated comment)
- Log in to comment
with the addition of DDL constructs to the compiler system, a public method of extending the compilation of new types of expression and schema constructs (such as AlterTable for migrate usage) should be added. I think it should be along the lines of people creating
Compiler
-like classes of their own which can somehow be registered along with the built in compilers. Multiple compilers without awareness of each other also would need to be supported, so that plugins from multiple libraries can coexist.