On 08/27/2012 10:13 PM, Michael Bayer wrote:
> I'm super-hot to get the first betas of 0.8 out the door, and as this is a 
> backwards-compatability-sensitive change, I was in a super rush to get this 
> in, so it's in tip.
> 
seen it' thanks again :).
> 
> 
> On Aug 27, 2012, at 12:49 PM, Michael Bayer wrote:
> 
>> Here's a patch:
>>
>> diff -r 594b0162e8a5 lib/sqlalchemy/sql/expression.py
>> --- a/lib/sqlalchemy/sql/expression.py       Mon Aug 27 12:33:10 2012 -0400
>> +++ b/lib/sqlalchemy/sql/expression.py       Mon Aug 27 12:43:48 2012 -0400
>> @@ -3110,7 +3110,7 @@
>>                 typemap[key] = sqltypes.to_instance(typemap[key])
>>
>>         def repl(m):
>> -            self.bindparams[m.group(1)] = bindparam(m.group(1))
>> +            self.bindparams[m.group(1)] = bindparam(m.group(1), 
>> required=True)
>>             return ':%s' % m.group(1)
>>
>>         # scan the string and search for bind parameter names, add them
>>
>>
>> however, this is too easy.  There's lots of other places binds are 
>> generated.   A rule such that if "value" is not passed to bindparam(), then 
>> flip the required flag on, would be the best behavior.  needs a few lines in 
>> the bindparam() function, but also would need a lot of tests, in 
>> test/sql/test_query.py.   ticket #2556 is added.
>>
>> for your immediate needs, you can make a function that returns a Text() 
>> construct, and just supplies a dictionary of bindparam() objects to the 
>> Text() pre-established, with the required=True flag turned on.
>>
>>
>>
>>
>>
>>
>> On Aug 27, 2012, at 12:06 PM, alex bodnaru wrote:
>>
>>>
>>> hello friends,
>>>
>>> for a migrated system, i'm using textual queries in the form:
>>>
>>> dbsession.execute("select name from table where id=:id", dict(id=1))
>>>
>>> to my surprise, "select ... id=:idd" would still "work", asuming idd is 
>>> null,
>>> despite 'idd' is not in bindparms.
>>
>>
>>
>>
>>>
>>> a 'required' argument to bindparam in _TextClause __init__() would indeed 
>>> make
>>> the 'idd' column required, thus raise an exception when not found in bind
>>> dict(id=1).
>>>
>>> is there an official way to acomplish this, or should i just hack in 
>>> hardcoded?
>>>
>>> thanks in advance,
>>> alex
>>>
>>> -- 
>>> 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 
>>> 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 sqlalchemy@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 sqlalchemy@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