From: Peter Rabbitson Date: Sat, 23 May 2009 21:37:19 +0000 (+0000) Subject: Make sure MultiColumnIn quotes column names while munging literal sql X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9f6b5584c111879dc9dbf845bcf2462fa7471646;p=dbsrgits%2FDBIx-Class-Historic.git Make sure MultiColumnIn quotes column names while munging literal sql Tested by running t/resultset/update_delete against pg with quote char " and name sep . --- diff --git a/lib/DBIx/Class/Storage/DBI/MultiColumnIn.pm b/lib/DBIx/Class/Storage/DBI/MultiColumnIn.pm index 050c018..0a48805 100644 --- a/lib/DBIx/Class/Storage/DBI/MultiColumnIn.pm +++ b/lib/DBIx/Class/Storage/DBI/MultiColumnIn.pm @@ -33,9 +33,10 @@ sub _multipk_update_delete { if ( ref $attrs->{select} ne 'ARRAY' or @{$attrs->{select}} != @pcols ); # This is hideously ugly, but SQLA does not understand multicol IN expressions + my $sqla = $self->_sql_maker; my ($sql, @bind) = @${$rs->as_query}; - $sql = sprintf ('(%s) IN %s', - join (', ', @pcols), + $sql = sprintf ('(%s) IN %s', # the as_query stuff is already enclosed in ()s + join (', ', map { $sqla->_quote ($_) } @pcols), $sql, ); diff --git a/t/resultset/update_delete.t b/t/resultset/update_delete.t index 8810418..fc535e6 100644 --- a/t/resultset/update_delete.t +++ b/t/resultset/update_delete.t @@ -13,8 +13,6 @@ my $schema = DBICTest->init_schema(); my $tkfks = $schema->resultset('FourKeys_to_TwoKeys'); -warn "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; - my ($fa, $fb) = $tkfks->related_resultset ('fourkeys')->populate ([ [qw/foo bar hello goodbye sensors read_count/], [qw/1 1 1 1 a 10 /],