[Rails] Bind Variables in Active Record
Rick Bradley
rick at rickbradley.com
Tue Dec 7 01:33:32 GMT 2004
* Michael Koziarski (koziarski at gmail.com) [041206 19:45]:
> 2) Mixing ? and %s is not supported i.e find_all(["id=? and
> first_name like '%s'", 3 "''''bob'''\'?"])
>
> Is there a legitimate case for this kind of query?
If we're voting I'm skeptical that there would be a legitimate case for
this, and it may get confusing later to try to support simultaneous use
of both different escapings (especially from underneath where the
individual database adapters are concerned). If it has to be done it's
not overly difficult, the only trick being to make sure the expansions
are done independently. In a pinch one possible mechanism would be to
convert %-expansions into '?' bindings:
find_all(["id=? and foo=%s and bar=%d", id, foo, bar]
=>
find_all(["id=? and foo=? and bar=?", id, foo, bar]
and then perform only one real type of expansion in the underlying
method.
Rick
--
http://www.rickbradley.com MUPRN: 453
| etc for both the booth
random email haiku | and theatre. At this point, I
| would say, go for it.
More information about the Rails
mailing list