From 24ee93f63e21fccae6cbc1cc1c154dd56f1e1963 Mon Sep 17 00:00:00 2001 From: Konstantin Tretyakov Date: Mon, 17 Dec 2018 23:03:17 +0100 Subject: [PATCH] Added the missing *kw parameter to compiler.process() calls in documentation examples --- lib/sqlalchemy/ext/compiler.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/sqlalchemy/ext/compiler.py b/lib/sqlalchemy/ext/compiler.py index 28fe45964d..6a0909d361 100644 --- a/lib/sqlalchemy/ext/compiler.py +++ b/lib/sqlalchemy/ext/compiler.py @@ -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`` -- 2.47.3