From be16b15f2c0dc33f2491fc6ad1de0f11b1f6c7d4 Mon Sep 17 00:00:00 2001 From: Ants Aasma Date: Sun, 19 Aug 2007 23:01:44 +0000 Subject: [PATCH] an early out processing insert/update column parameters was a bit too early. --- lib/sqlalchemy/sql/compiler.py | 10 +++++----- test/sql/query.py | 6 ++++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index e9046b4072..59eb3cdb39 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -681,11 +681,6 @@ class DefaultCompiler(engine.Compiled, visitors.ClauseVisitor): self.binds[col.key] = bindparam return self.bindparam_string(self._truncate_bindparam(bindparam)) - # no parameters in the statement, no parameters in the - # compiled params - return binds for all columns - if self.parameters is None and stmt.parameters is None: - return [(c, create_bind_param(c, None)) for c in stmt.table.columns] - def create_clause_param(col, value): self.traverse(value) self.inline_params.add(col) @@ -699,6 +694,11 @@ class DefaultCompiler(engine.Compiled, visitors.ClauseVisitor): else: return key + # no parameters in the statement, no parameters in the + # compiled params - return binds for all columns + if self.parameters is None and stmt.parameters is None: + return [(c, create_bind_param(c, None)) for c in stmt.table.columns] + # if we have statement parameters - set defaults in the # compiled params if self.parameters is None: diff --git a/test/sql/query.py b/test/sql/query.py index 8ec3190b4d..ddd5348c45 100644 --- a/test/sql/query.py +++ b/test/sql/query.py @@ -145,6 +145,12 @@ class QueryTest(PersistTest): s = select([users], users.c.user_id==bindparam('id')).compile() c = testbase.db.connect() assert c.execute(s, id=7).fetchall()[0]['user_id'] == 7 + + def test_compiled_insert_execute(self): + users.insert().compile().execute(user_id = 7, user_name = 'jack') + s = select([users], users.c.user_id==bindparam('id')).compile() + c = testbase.db.connect() + assert c.execute(s, id=7).fetchall()[0]['user_id'] == 7 def test_repeated_bindparams(self): """test that a BindParam can be used more than once. -- 2.47.3