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