Query Bind values with string keys

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Query Bind values with string keys

Sampson Crowley
Is it possible to use string keys for named query params? I have a very dynamic query builder for and Admin site, and I would like to avoid the extra memory use of permanently storing every key used as a symbol

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/15e21d12-8d43-415c-8b19-5966ee93d22a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Query Bind values with string keys

Ariel Juodziukynas
can you show an example of your code? you can always do "somestring" => "somevalue" instead of somestring: "somevalue"

El mié., 12 jun. 2019 a las 15:24, Sampson Crowley (<[hidden email]>) escribió:
Is it possible to use string keys for named query params? I have a very dynamic query builder for and Admin site, and I would like to avoid the extra memory use of permanently storing every key used as a symbol

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/15e21d12-8d43-415c-8b19-5966ee93d22a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAPS3bcDPHqQLZxG6x27pNRYC4gSMvO7EQS9-W8%3Du-anoLwryTw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Query Bind values with string keys

Sampson Crowley
Nope, you can't always just do that

SomeModel.where("my_column = :named", {"named" => "value"})

Doesn't work. You get a arg not found error

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/4ef0ea26-1efd-4b59-b002-c6e1dabeeac1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.