thanks michael,

On 08/27/2012 07: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
> 
that's what i did indeed.
but it would break queries that are happy with the null on missing default.
thus, a configurable option, false by default, would do the job.
> 
> 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.
thank you very much. the patch is very sensible, but it will certainly break
scripts that rely on the null on missing behaviour.
however, i don't have such scripts ;).
> 
> 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.
> 
thought of it too, but it won't do the work: i needed to catch :variables
missing in the given bindparm.
> 
> 
> 
thanks a lot,
alex
> 
> 
> 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.

Reply via email to