Jeff Peck wrote:
> I recently tried out 0.6 beta 3, and I noticed that the following
> construct is no longer allowed using the sql expression language:
>
> def update_foos(connection, foo_items):
>     update = foo_table.update(
>         foo_table.c.id == bindparam('id'),
>         values = { 'column_1' : bindparam('column_1'),  .......}
>         )
>     connection.execute(update, foo_items)
>
>
> Apparently you can't specify a bindparam in the where clause now. I
> was just kind of curious as to what led to this change, and what is
> the recommended way of doing this now? Should I have been doing this
> in the first place?

that's not accurate.  you can specify bindparams() anywhere in the
statement.  It is the *name* of the bindparam which matches that of a
column that is reserved for the SET clause of the statement - this is why
the error says:  "Bind parameter name 'foo' is reserved for the VALUES or
SET clause of this insert/update statement".

Above, you don't even need the "values" phrase - bindparams that are named
the same as the column are implicit (it has always been this way):

foo_items = [
    {'table_id':id, 'column_1':col1, 'column_2':col2, ...} for id, col1,
col2, ... in data
]

update = foo_table.update().where(foo_table.c.id == bindparam('table_id'))
connection.execute(update, foo_items)

Given the above behavior, the change is that the compiler needn't spend a
dozen function calls guessing whether the parameter keys passed to
execute() are intended for usage with user-specific bindparam()
constructs, or the "implicit" parameter constructs used for the SET clause
(this guessing also didn't work completely, so it was removed).

I will add further detail to the error message.




>
>
> Thanks,
> Jeff Peck
>
> --
> You received this message because you are subscribed to the Google Groups
> "sqlalchemy" group.
> To post to this group, send email to sqlalch...@googlegroups.com.
> To unsubscribe from this group, send email to
> sqlalchemy+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/sqlalchemy?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to