Hi ! I have an instance where I'd like to use the automatic value quoting that sanitize conditions provides. Here's the SQL: SELECT COUNT(*) FROM tournaments INNER JOIN entries ON entries.tournament_id = tournaments.id INNER JOIN plays ON plays.entry_id = entries.id WHERE #{self.class.sanitize_sql([conds.join(' AND '), values])} Unfortunately, I get a NoMethodError because sanitize_sql is protected. Is there a particular reason why this is protected ? Thanks ! -- François Beausoleil http://blog.teksol.info/ _______________________________________________ Rails-core mailing list Rails-core@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-core
On 12/9/05, Francois Beausoleil <francois.beausoleil@gmail.com> wrote:> Hi ! > > I have an instance where I''d like to use the automatic value quoting > that sanitize conditions provides. Here''s the SQL: > SELECT COUNT(*) FROM tournaments > INNER JOIN entries ON entries.tournament_id = tournaments.id > INNER JOIN plays ON plays.entry_id = entries.id > WHERE #{self.class.sanitize_sql([conds.join('' AND ''), values])} > > Unfortunately, I get a NoMethodError because sanitize_sql is protected. > > Is there a particular reason why this is protected ?Usually methods are marked as protected when we don''t want to make them part of the public API. Every time someone calls our ''implementation'' methods we either break their applications, or lose the option to refactor that code. -- Cheers Koz
2005/12/8, Michael Koziarski <michael@koziarski.com>:> On 12/9/05, Francois Beausoleil <francois.beausoleil@gmail.com> wrote: > > Is there a particular reason why this is protected ? > > Usually methods are marked as protected when we don't want to make > them part of the public API. Every time someone calls our > 'implementation' methods we either break their applications, or lose > the option to refactor that code.I understand that, but is there a way to make something like #sanitize_sql available for the general public ? Isn't it a useful method ? In my application, I did it another way - I used #count, which ends up calling count_by_sql. The nice thing is that #sanitize_sql was called, so I simply had to provide the parameters in the right format. In that case, maybe it's not such a useful method... Anyway, thanks for the heads up ! -- François Beausoleil http://blog.teksol.info/ _______________________________________________ Rails-core mailing list Rails-core@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-core