On 4/13/07, Ivan Fomichev <[EMAIL PROTECTED]> wrote:
Hello, Lee,2007/4/13, Lee Standen <[EMAIL PROTECTED]>: > Or, you could take the other tact, and argue that it should be something > which is handled on the Perl side... > > my $rs = $schema->resultset('Patient')->search({ > -and => [ > first_name => { like => 'J%' }, > birth_date => { '>' => time - 20 * SECONDS_IN_YEAR } > ] > }); > > Yes, while it's POSSIBLE to do that in an SQL statement, I prefer to > think as DBIx::Class not as an SQL abstractor, but as a data object > extractor, which means anything that requires me to use SQL specific > commands is bad :) >
I also don't like putting any complex SQL in my DBIC statements, but I prefer to solve it the other way around: push this stuff down to the actual DB, by creating views or stored procedures. I don't know if this case is simple enough to qualify (especially if the birth_date cutoff in years is variable based on user input), but you see what I mean in general. The "do it in perl" option isn't bad either, and might especially be nice in this instance where (a) its simple, and (b) it doesn't involve perl-side row filtering, so its not like you're increasing DB load by doing it in perl. -- Brandon _______________________________________________ List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class Wiki: http://dbix-class.shadowcatsystems.co.uk/ IRC: irc.perl.org#dbix-class SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/ Searchable Archive: http://www.mail-archive.com/[EMAIL PROTECTED]/
