[Sqlalchemy-tickets] Issue #3098: Percent sign formatting of ddl strings breaks for modulo operatio
Brought to you by:
zzzeek
|
From: mike_solomon <iss...@bi...> - 2014-06-26 08:59:12
|
New issue 3098: Percent sign formatting of ddl strings breaks for modulo operations on columns that start with f, d, etc. https://bitbucket.org/zzzeek/sqlalchemy/issue/3098/percent-sign-formatting-of-ddl-strings mike_solomon: The following code does not compile because there is a % f in it (from the modulo operation on the table foo) and the visit_ddl function in compiler.py uses python's percent sign formatting syntax. ``` #!python from sqlalchemy import Table, MetaData, Column, Integer, DDL from sqlalchemy import create_engine, event ECHO = False engine = create_engine('sqlite:///memory', echo=ECHO) ddl = DDL( '''CREATE TRIGGER foo AFTER INSERT ON bar BEGIN INSERT INTO bar SELECT * FROM foo WHERE 2 % foo.id = 0; END; ''' ) md = MetaData() Foo = Table('foo', md, Column('id', Integer)) Bar = Table('bar', md, Column('id', Integer)) event.listen(Foo, 'after_create', ddl.execute_if(dialect='sqlite')) Foo.metadata.create_all(engine) ``` |