From: Norbert Buchmuller Date: Tue, 25 Nov 2008 04:23:16 +0000 (+0100) Subject: * Made some more tests SKIP if SQLA version < 1.50. X-Git-Tag: v0.08240~189^2~22 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=89479564f69e12460c2740d1d74c6a1253af18cb;p=dbsrgits%2FDBIx-Class.git * Made some more tests SKIP if SQLA version < 1.50. --- diff --git a/WHATSNEW.txt b/WHATSNEW.txt index 136b132..42521d3 100644 --- a/WHATSNEW.txt +++ b/WHATSNEW.txt @@ -1,4 +1,4 @@ -NOTE: do not merge this file +NOTE: do not merge this file but DELETE IT on merge New in this branch: @@ -25,9 +25,9 @@ New in this branch: * the testcase changes broke compatibility with old SQLA * Added test cases to test if arrayref bind values in insert/update are passed through sql_maker intact. + * Added test cases to test if arrayref bind values work with a PostgreSQL array type. * Added 'array_datatypes' parameter to the sql_maker constructor. * formerly SQLA considered these as literal SQL with bind values, now that is \['literal SQL', @bind] * the new syntax is consistent (works the same in insert/update and where conditions) * fortunately 'array_datatypes' is simply ignored by old SQLA (at least with current version..) - * mst told me that DBD::Pg can use arrayref bind values for PostgreSQL array types - * did not work for me, not sure if it is really so + * DBD::Pg can use arrayref bind values for PostgreSQL array types diff --git a/t/95sql_maker.t b/t/95sql_maker.t index 0971d12..900e604 100644 --- a/t/95sql_maker.t +++ b/t/95sql_maker.t @@ -21,33 +21,37 @@ my $schema = DBICTest->init_schema(); my $sql_maker = $schema->storage->sql_maker; -my ($sql, @bind) = $sql_maker->insert( - 'lottery', - { - 'day' => '2008-11-16', - 'numbers' => [13, 21, 34, 55, 89] - } -); - -is_same_sql_bind( - $sql, \@bind, - q/INSERT INTO lottery (day, numbers) VALUES (?, ?)/, - [ ['day' => '2008-11-16'], ['numbers' => [13, 21, 34, 55, 89]] ], - 'sql_maker passes arrayrefs in insert' -); - - -($sql, @bind) = $sql_maker->update( - 'lottery', - { - 'day' => '2008-11-16', - 'numbers' => [13, 21, 34, 55, 89] - } -); - -is_same_sql_bind( - $sql, \@bind, - q/UPDATE lottery SET day = ?, numbers = ?/, - [ ['day' => '2008-11-16'], ['numbers' => [13, 21, 34, 55, 89]] ], - 'sql_maker passes arrayrefs in update' -); +SKIP: { + skip "SQL::Abstract < 1.50 does not pass through arrayrefs", 2 if $SQL::Abstract::VERSION < 1.50; + + my ($sql, @bind) = $sql_maker->insert( + 'lottery', + { + 'day' => '2008-11-16', + 'numbers' => [13, 21, 34, 55, 89] + } + ); + + is_same_sql_bind( + $sql, \@bind, + q/INSERT INTO lottery (day, numbers) VALUES (?, ?)/, + [ ['day' => '2008-11-16'], ['numbers' => [13, 21, 34, 55, 89]] ], + 'sql_maker passes arrayrefs in insert' + ); + + + ($sql, @bind) = $sql_maker->update( + 'lottery', + { + 'day' => '2008-11-16', + 'numbers' => [13, 21, 34, 55, 89] + } + ); + + is_same_sql_bind( + $sql, \@bind, + q/UPDATE lottery SET day = ?, numbers = ?/, + [ ['day' => '2008-11-16'], ['numbers' => [13, 21, 34, 55, 89]] ], + 'sql_maker passes arrayrefs in update' + ); +} diff --git a/t/95sql_maker_quote.t b/t/95sql_maker_quote.t index 56a8072..5fef846 100644 --- a/t/95sql_maker_quote.t +++ b/t/95sql_maker_quote.t @@ -111,58 +111,62 @@ is_same_sql_bind( 'scalar ORDER BY okay (multiple values)' ); +SKIP: { + skip "SQL::Abstract < 1.50 does not support hashrefs in order_by", 2 if $SQL::Abstract::VERSION < 1.50; -($sql, @bind) = $sql_maker->select( - [ - { - 'me' => 'cd' - } - ], - [ - 'me.cdid', - 'me.artist', - 'me.title', - 'me.year' - ], - undef, - { -desc => 'year' }, - undef, - undef -); + ($sql, @bind) = $sql_maker->select( + [ + { + 'me' => 'cd' + } + ], + [ + 'me.cdid', + 'me.artist', + 'me.title', + 'me.year' + ], + undef, + { -desc => 'year' }, + undef, + undef + ); -is_same_sql_bind( - $sql, \@bind, - q/SELECT `me`.`cdid`, `me`.`artist`, `me`.`title`, `me`.`year` FROM `cd` `me` ORDER BY `year` DESC/, [], - 'hashref ORDER BY okay (single value)' -); + is_same_sql_bind( + $sql, \@bind, + q/SELECT `me`.`cdid`, `me`.`artist`, `me`.`title`, `me`.`year` FROM `cd` `me` ORDER BY `year` DESC/, [], + 'hashref ORDER BY okay (single value)' + ); -($sql, @bind) = $sql_maker->select( - [ - { - 'me' => 'cd' - } - ], - [ - 'me.cdid', - 'me.artist', - 'me.title', - 'me.year' - ], - undef, - [ - { -desc => 'year' }, - { -asc => 'title' } - ], - undef, - undef -); + ($sql, @bind) = $sql_maker->select( + [ + { + 'me' => 'cd' + } + ], + [ + 'me.cdid', + 'me.artist', + 'me.title', + 'me.year' + ], + undef, + [ + { -desc => 'year' }, + { -asc => 'title' } + ], + undef, + undef + ); + + is_same_sql_bind( + $sql, \@bind, + q/SELECT `me`.`cdid`, `me`.`artist`, `me`.`title`, `me`.`year` FROM `cd` `me` ORDER BY `year` DESC, `title` ASC/, [], + 'hashref ORDER BY okay (multiple values)' + ); -is_same_sql_bind( - $sql, \@bind, - q/SELECT `me`.`cdid`, `me`.`artist`, `me`.`title`, `me`.`year` FROM `cd` `me` ORDER BY `year` DESC, `title` ASC/, [], - 'hashref ORDER BY okay (multiple values)' -); +} ($sql, @bind) = $sql_maker->select(