Sorry, I'm having difficulties following your explanation. Would you mind extending on it a bit?
that error should only occur if the list of elements you're passing to > insert.values() contains inconsistent keys. As long as each dictionary > has the same keys, that error won't occur. > With "keys", do you mean the primary key column in your example (the 'id' column)? Or column 'foo'? The old behavior was a bug, we just kept it at 1.1 in case people were > relying upon the buggy > behavior of it forcing NULL for columns where a default generator should > have been used. > So, if I upgrade to 1.1 the old behaviour will be restored? Are there any plans of making it a feature and maintaining it? values = [ > {'id': 1, 'data': 'data1', 'foo': 'plainfoo'}, > {'id': 2, 'data': 'data2'}, > {'id': 3, 'data': 'data3', 'foo': 'otherfoo'}, > ] > Which one of those dicts causes the issue and why? Is it the fact that 'foo' is being set client-side, that the id=2 row has no value, that the id=1 and id=3 rows have different values? What's the "proper" way of resolving this without relying on buggy (and potentially not maintained) behaviour? Thanks for your help. On Monday, 18 January 2016 18:23:04 UTC+11, gbr wrote: > > I've upgraded from a SQLA version 0.9.x to 1.0.9. Previously, I did the > following when inserting new records: > > - Column('flag', Boolean, server_default=sql.expression.false()) I didn't set > those columns locally and didn't include them in the insert statement when I > wanted them to be False > - Column('date', Date, nullable=False) I didn't set those columns as part of > the insert when I wanted `date=None` > - Column('number', Float, nullable=True) I assigned integer values to the > column which were implicitly "casted" to floats > > This behaviour changed which is described here > (http://docs.sqlalchemy.org/en/latest/changelog/migration_10.html#python-side-defaults-invoked-for-each-row-invidually-when-using-a-multivalued-insert) > > My question which (perhaps all?) of the above things I did could have caused > the error message below (with the upgrade). Can I reinstate the old behaviour > (is there a global SQLA parameter I could configure?) or some other way of > making sure I fix all places where the above bullet points still apply? > > File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/scoping.py", > line 150, in do > return getattr(self.registry(), name)(*args, **kwargs) > File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", > line 1034, in execute > bind, close_with_result=True).execute(clause, params or {}) > File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", > line 914, in execute > return meth(self, multiparams, params) > File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/elements.py", > line 323, in _execute_on_connection > return connection._execute_clauseelement(self, multiparams, params) > File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", > line 1003, in _execute_clauseelement > inline=len(distilled_params) > 1) > File "<string>", line 1, in <lambda> > File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/elements.py", > line 494, in compile > return self._compiler(dialect, bind=bind, **kw) > File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/elements.py", > line 500, in _compiler > return dialect.statement_compiler(dialect, self, **kw) > File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/compiler.py", > line 392, in __init__ > Compiled.__init__(self, dialect, statement, **kwargs) > File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/compiler.py", > line 190, in __init__ > self.string = self.process(self.statement, **compile_kwargs) > File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/compiler.py", > line 213, in process > return obj._compiler_dispatch(self, **kwargs) > File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/visitors.py", > line 81, in _compiler_dispatch > return meth(self, **kw) > File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/compiler.py", > line 1819, in visit_insert > crud_params = crud._get_crud_params(self, insert_stmt, **kw) > File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/crud.py", line > 113, in _get_crud_params > values = _extend_values_for_multiparams(compiler, stmt, values, kw) > File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/crud.py", line > 503, in _extend_values_for_multiparams > for i, row in enumerate(stmt.parameters[1:]) > File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/crud.py", line > 503, in <genexpr> > for i, row in enumerate(stmt.parameters[1:]) > File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/crud.py", line > 336, in _process_multiparam_default_bind > "a Python-side value or SQL expression is required" % c) > CompileError: INSERT value for column table.number is explicitly rendered as > a boundparameter in the VALUES clause; a Python-side value or SQL expression > is required > > -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at https://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.