in reply to Concrete SQL from SQL::Abstract?

UPDATE on this topic - you can simply use the DBI quote method instead of SQL::DB like so:
sub query_as_string { my ($sql, @bind)=@_; # [14:50] <ilmari> metaperl: s/\?/$dbh->quote(shift @bind)/ge $_ = $sql; s/\?/$dbh->quote(shift @bind)/ge ; $_; }




The mantra of every experienced web application developer is the same: thou shalt separate business logic from display. Ironically, almost all template engines allow violation of this separation principle, which is the very impetus for HTML template engine development.

-- Terence Parr, "Enforcing Strict Model View Separation in Template Engines"

Replies are listed 'Best First'.
Re^2: Concrete SQL from SQL::Abstract?
by benizi (Hermit) on Sep 26, 2010 at 07:11 UTC

    Thanks. Hadn't logged on in a while (unfortunately).

    You should localize $_ there.

    local $_ = $sql;

    instead of:

    $_ = $sql;

    This has some quoting problems, but it's not your code's fault. Since SQL::Abstract doesn't use $dbh->quote_identifier, it can return invalid SQL. E.g. MySQL (at least) allows question marks in table names: mysql -Dtest -e 'create table `o rly?` (a int)'

    In the end, it didn't matter much anyway, as I was stuck doing most of my work in PHP. In that realm, nothing holds a candle to DBI