]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Added the missing *kw parameter to compiler.process() calls in documentation examples 4402/head
authorKonstantin Tretyakov <kt@ut.ee>
Mon, 17 Dec 2018 22:03:17 +0000 (23:03 +0100)
committerKonstantin Tretyakov <kt@ut.ee>
Mon, 17 Dec 2018 22:03:17 +0000 (23:03 +0100)
lib/sqlalchemy/ext/compiler.py

index 28fe45964d995ce0b1b1ec093227f99601e8ab52..6a0909d36185fa7af820622cd2c15aa80856b7f5 100644 (file)
@@ -85,8 +85,8 @@ method which can be used for compilation of embedded attributes::
     @compiles(InsertFromSelect)
     def visit_insert_from_select(element, compiler, **kw):
         return "INSERT INTO %s (%s)" % (
-            compiler.process(element.table, asfrom=True),
-            compiler.process(element.select)
+            compiler.process(element.table, asfrom=True, **kw),
+            compiler.process(element.select, **kw)
         )
 
     insert = InsertFromSelect(t1, select([t1]).where(t1.c.x>5))
@@ -119,10 +119,11 @@ below where we generate a CHECK constraint that embeds a SQL expression::
 
     @compiles(MyConstraint)
     def compile_my_constraint(constraint, ddlcompiler, **kw):
+        kw['literal_binds'] = True
         return "CONSTRAINT %s CHECK (%s)" % (
             constraint.name,
             ddlcompiler.sql_compiler.process(
-                constraint.expression, literal_binds=True)
+                constraint.expression, **kw)
         )
 
 Above, we add an additional flag to the process step as called by
@@ -265,13 +266,13 @@ A synopsis is as follows:
 
       @compiles(coalesce)
       def compile(element, compiler, **kw):
-          return "coalesce(%s)" % compiler.process(element.clauses)
+          return "coalesce(%s)" % compiler.process(element.clauses, **kw)
 
       @compiles(coalesce, 'oracle')
       def compile(element, compiler, **kw):
           if len(element.clauses) > 2:
               raise TypeError("coalesce only supports two arguments on Oracle")
-          return "nvl(%s)" % compiler.process(element.clauses)
+          return "nvl(%s)" % compiler.process(element.clauses, **kw)
 
 * :class:`~sqlalchemy.schema.DDLElement` - The root of all DDL expressions,
   like CREATE TABLE, ALTER TABLE, etc. Compilation of ``DDLElement``