need to pg-escape DDL sequences

Issue #1897 resolved
Mike Bayer repo owner created an issue
--- a/lib/sqlalchemy/sql/compiler.py    Sun Aug 29 18:13:44 2010 -0400
+++ b/lib/sqlalchemy/sql/compiler.py    Mon Aug 30 12:37:57 2010 -0400
@@ -1121,7 +1121,7 @@
             context.setdefault('schema', sch)
             context.setdefault('fullname', preparer.format_table(ddl.target))

-        return ddl.statement % context
+        return self.sql_compiler.post_process_text(ddl.statement % context)

     def visit_create_table(self, create):
         table = create.element

we might need this for other DBAPIs as well

Comments (3)

  1. Mike Bayer reporter

    i.e.:

    from sqlalchemy import *
    
    e = create_engine('postgresql://scott:tiger@localhost/test', echo=True)
    
    # works
    e.execute(text("select foo%something"))
    
    # doesn't work (note the %% is part of DDL)
    e.execute(DDL("select foo%%something"))
    
    # triple escaping works
    e.execute(DDL("select foo%%%%something"))
    
  2. Log in to comment