]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
an early out processing insert/update column parameters was a bit too early.
authorAnts Aasma <ants.aasma@gmail.com>
Sun, 19 Aug 2007 23:01:44 +0000 (23:01 +0000)
committerAnts Aasma <ants.aasma@gmail.com>
Sun, 19 Aug 2007 23:01:44 +0000 (23:01 +0000)
lib/sqlalchemy/sql/compiler.py
test/sql/query.py

index e9046b40725742a15994870e2f71b77c4473bad3..59eb3cdb39d354a14a21be7e97c8bbf8eb1872c5 100644 (file)
@@ -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:
index 8ec3190b4d883cf799f2ddae103342a8cce1a7fd..ddd5348c4521f8f0fe8a97f95e2edcedddc33fb4 100644 (file)
@@ -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.