On May 18, 10:04 pm, "S. Robert James" <[EMAIL PROTECTED]> wrote:
> A lot of plugins would be easier if there was a way, instead of
> executing a find, to get the SQL it would use as a String (or perhaps
> an array of a string and bind variables).
>
> This would make it easier to do a lot of powerful queries at the
> database, while still taking advantage of Rails' to manage the basic
> structure. Make it easier to DRY up some of those tough finder
> methods.
>
> Any way of doing this? What are others' thoughts about the utility of
> this?
I've been working on ActiveRecord patches this week so I know a bit
about its internals. The function you want is
ActiveRecord::Base.sanitize_sql(). Given a find()-condition-like
parameter (such as ['foo = ?', bar], {:foo => :bar}, and things like
that) it will return a piece of SQL.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---