]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commitdiff
Autogenerate renderer for op.ExecuteSQLOp
authorJacob Magnusson <m@jacobian.se>
Thu, 29 Oct 2015 11:14:20 +0000 (12:14 +0100)
committerJacob Magnusson <m@jacobian.se>
Thu, 29 Oct 2015 16:01:24 +0000 (17:01 +0100)
Asserts that the passed in sqltext is a string to simplify the
implementation. Generates a op.execute(sqltext) line.

alembic/autogenerate/render.py

index 9a64641004af708bfd84a176a50e003e37e4d33c..f9c6bc776b052e75270e56f6ae56a3932eec4500 100644 (file)
@@ -721,4 +721,14 @@ def _render_check_constraint(constraint, autogen_context):
     }
 
 
+@renderers.dispatch_for(ops.ExecuteSQLOp)
+def _execute_sql(autogen_context, op):
+    if not isinstance(op.sqltext, string_types):
+        raise NotImplementedError(
+            "Autogenerate rendering of SQL Expression language constructs "
+            "not supported here; please use a plain SQL string"
+        )
+    return 'op.execute(%r)' % op.sqltext
+
+
 renderers = default_renderers.branch()