zzzeek / test_sqlalchemy

0 stars 0 forks source link

user-defined compileable statements ? #958

Closed sqlalchemy-bot closed 15 years ago

sqlalchemy-bot commented 16 years ago

Issue created by Michael Bayer (zzzeek)


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')
sqlalchemy-bot commented 10 years ago

Michael Bayer (zzzeek) wrote:


Removing milestone: 0.6.0 (automated comment)

sqlalchemy-bot commented 15 years ago

Michael Bayer (zzzeek) wrote:


an extension for this is present in 0.6, but needs simplification - for that we have #1331.

sqlalchemy-bot commented 15 years ago

Michael Bayer (zzzeek) wrote:


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.

sqlalchemy-bot commented 10 years ago

Changes by Michael Bayer (zzzeek): removed "0.6.0" milestone

sqlalchemy-bot commented 15 years ago

Changes by Michael Bayer (zzzeek): set state to "resolved"

sqlalchemy-bot commented 15 years ago

Changes by Michael Bayer (zzzeek): changed milestone from "blue sky" to "0.6.0"