On Apr 24, 2007, at 8:36 PM, Monty Taylor wrote:

>
> When I get into visit_update and look into the  
> update_stmt.whereclause,
> I have a CompoundClause, which contains a single clause, and an AND
> condition, which is cool. But when I look at the clause, I have a  
> column
> and a parameter. If I print column.id and parameter.__dict__, I get:
>
> id {'shortname': 'testproject_id', 'unique': True, 'type': Integer(),
> 'value': None, 'key': 'testproject_id'}
>
> Why is the value none? Shouldn't we know that project1 has an id of  
> 291?
> Do I need to do something in a visitor to fill in the value here that
> I'm not doing? Is it expected that the ExecutionContext provides this
> value from the object in some way?
>

the "value" field inside of _BindParamClause, which is what youre  
looking at there, is optional.  its usually set when you do things like:

mytable.c.somecolumn == 5

because we have a "5" there, it becomes literal(5) which is just  
_BindParamClause('literal', 5, unique=True).  the "5" is bound to the  
bind param.

but bind params can just be names, and the values come in with the  
execute() arguments.  you can also mix both approaches in which case  
the params sent to execute() override the bind param values.

so im guessing youre looking at the Updates created inside of  
mapper.save_obj(), which look like, in a simplified way:

u = table.update(col == sql.bindparam('pk_column'))

i.e. bind param with no value.  and then it executes via

u.execute({'pk_column': 291, 'col_1': <col1value>, 'col_2':  
<col2value> ...})




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

Reply via email to