- marked as critical
- edited description
multi-valued insert isn't checking additonal values for literal
Issue #3069
resolved
from sqlalchemy import create_engine, MetaData, Table, Integer, Date, Column
import sqlalchemy.sql as sql
md = MetaData()
table = Table("data", md)
table.append_column(Column("id", Integer))
table.append_column(Column("adate", Date))
table.append_column(Column("value", Integer))
data = [
{"id": 1, "value": "foo", "adate": sql.func.now()},
{"id": 2, "value": "bar", "adate": sql.func.now()}
]
stmt = table.insert().values(data)
from sqlalchemy.dialects import postgresql
print stmt.compile(dialect=postgresql.dialect())
INSERT INTO data (id, adate, value) VALUES (%(id_0)s, now(), %(value_0)s), (%(id_1)s, %(adate_1)s, %(value_1)s)
patch:
index cd01ea5..dff4c99 100644
--- a/lib/sqlalchemy/sql/compiler.py
+++ b/lib/sqlalchemy/sql/compiler.py
@@ -2207,10 +2207,12 @@ class SQLCompiler(Compiled):
[
(
c,
- self._create_crud_bind_param(
+ (self._create_crud_bind_param(
c, row[c.key],
name="%s_%d" % (c.key, i + 1)
- )
+ ) if elements._is_literal(row[c.key])
+ else self.process(
+ row[c.key].self_group(), **kw))
if c.key in row else param
)
for (c, param) in values_0
the current behavior is totally wrong. safe to go in
Comments (7)
-
reporter -
reporter - changed milestone to 0.9.7
-
reporter - edited description
-
reporter - changed status to resolved
- Fixed bug where multi-valued :class:
.Insert
construct would fail to check subsequent values entries beyond the first one given for literal SQL expressions. fixes#3069
→ <<cset eb4abda81172>>
-
reporter - Fixed bug where multi-valued :class:
.Insert
construct would fail to check subsequent values entries beyond the first one given for literal SQL expressions. fixes#3069
→ <<cset 6fad9651b722>>
- Fixed bug where multi-valued :class:
-
reporter - changed milestone to 0.9.8
-
reporter - changed milestone to 0.9.7
- Log in to comment