[Bast-commits] r6299 - in DBIx-Class/0.08/branches/joined_count: .
lib/DBIx/Class t t/lib/DBIC
ribasushi at dev.catalyst.perl.org
ribasushi at dev.catalyst.perl.org
Mon May 18 17:27:39 GMT 2009
Author: ribasushi
Date: 2009-05-18 17:27:38 +0000 (Mon, 18 May 2009)
New Revision: 6299
Modified:
DBIx-Class/0.08/branches/joined_count/
DBIx-Class/0.08/branches/joined_count/lib/DBIx/Class/SQLAHacks.pm
DBIx-Class/0.08/branches/joined_count/t/42toplimit.t
DBIx-Class/0.08/branches/joined_count/t/lib/DBIC/SqlMakerTest.pm
Log:
r6290 at Thesaurus (orig r6289): ribasushi | 2009-05-17 00:06:40 +0200
Rewrite SqlMakerTest to fully depend on SQLA::Test
Allow is_same_sql_bind to accept an arrayrefref instead of any pair of $sql, \@bind
r6299 at Thesaurus (orig r6298): frew | 2009-05-18 18:16:44 +0200
Fix order by clauses for MSSQL
Property changes on: DBIx-Class/0.08/branches/joined_count
___________________________________________________________________
Name: svk:merge
- 168d5346-440b-0410-b799-f706be625ff1:/DBIx-Class-current:2207
462d4d0c-b505-0410-bf8e-ce8f877b3390:/local/bast/DBIx-Class:3159
4d5fae46-8e6a-4e08-abee-817e9fb894a2:/local/bast/DBIx-Class/0.08/branches/resultsetcolumn_custom_columns:5160
4d5fae46-8e6a-4e08-abee-817e9fb894a2:/local/bast/DBIx-Class/0.08/branches/sqla_1.50_compat:5414
4d5fae46-8e6a-4e08-abee-817e9fb894a2:/local/bast/DBIx-Class/0.08/trunk:5969
9c88509d-e914-0410-b01c-b9530614cbfe:/local/DBIx-Class:32260
9c88509d-e914-0410-b01c-b9530614cbfe:/local/DBIx-Class-CDBICompat:54993
9c88509d-e914-0410-b01c-b9530614cbfe:/vendor/DBIx-Class:31122
ab17426e-7cd3-4704-a2a2-80b7c0a611bb:/local/dbic_column_attr:10946
ab17426e-7cd3-4704-a2a2-80b7c0a611bb:/local/dbic_trunk:11142
bd5ac9a7-f185-4d95-9186-dbb8b392a572:/local/os/bast/DBIx-Class/0.08/trunk:2798
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/belongs_to_null_col_fix:5244
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/cdbicompat_integration:4160
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/column_attr:5074
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/complex_join_rels:4589
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/count_distinct:6218
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/file_column:3920
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/fix-update-and-delete-as_query:6162
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/multi_stuff:5565
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/on_disconnect_do:3694
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/oracle-tweaks:6222
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/oracle_sequence:4173
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/parser_fk_index:4485
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/prefetch:5699
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/replication_dedux:4600
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/rt_bug_41083:5437
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/savepoints:4223
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/sqla_1.50_compat:5321
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/storage-ms-access:4142
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/storage-tweaks:6262
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/subclassed_rsset:5930
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/subquery:5617
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/sybase:5651
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/sybase_mssql:6125
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/versioned_enhancements:4125
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/versioning:4578
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/views:5585
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/trunk:6281
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-C3:318
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-current:2222
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-joins:173
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-resultset:570
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/datetime:1716
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/find_compat:1855
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/find_unique_query_fixes:2142
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/inflate:1988
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/many_to_many:2025
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/re_refactor_bugfix:1944
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/reorganize_tests:1827
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/resultset-new-refactor:1766
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/resultset_2_electric_boogaloo:2175
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/resultset_cleanup:2102
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/sqlt_tests_refactor:2043
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/trunk/DBIx-Class:3606
fe160bb6-dc1c-0410-9f2b-d64a711b54a5:/local/DBIC-trunk-0.08:10510
+ 168d5346-440b-0410-b799-f706be625ff1:/DBIx-Class-current:2207
462d4d0c-b505-0410-bf8e-ce8f877b3390:/local/bast/DBIx-Class:3159
4d5fae46-8e6a-4e08-abee-817e9fb894a2:/local/bast/DBIx-Class/0.08/branches/resultsetcolumn_custom_columns:5160
4d5fae46-8e6a-4e08-abee-817e9fb894a2:/local/bast/DBIx-Class/0.08/branches/sqla_1.50_compat:5414
4d5fae46-8e6a-4e08-abee-817e9fb894a2:/local/bast/DBIx-Class/0.08/trunk:5969
9c88509d-e914-0410-b01c-b9530614cbfe:/local/DBIx-Class:32260
9c88509d-e914-0410-b01c-b9530614cbfe:/local/DBIx-Class-CDBICompat:54993
9c88509d-e914-0410-b01c-b9530614cbfe:/vendor/DBIx-Class:31122
ab17426e-7cd3-4704-a2a2-80b7c0a611bb:/local/dbic_column_attr:10946
ab17426e-7cd3-4704-a2a2-80b7c0a611bb:/local/dbic_trunk:11142
bd5ac9a7-f185-4d95-9186-dbb8b392a572:/local/os/bast/DBIx-Class/0.08/trunk:2798
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/belongs_to_null_col_fix:5244
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/cdbicompat_integration:4160
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/column_attr:5074
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/complex_join_rels:4589
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/count_distinct:6218
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/file_column:3920
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/fix-update-and-delete-as_query:6162
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/multi_stuff:5565
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/on_disconnect_do:3694
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/oracle-tweaks:6222
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/oracle_sequence:4173
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/parser_fk_index:4485
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/prefetch:5699
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/replication_dedux:4600
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/rt_bug_41083:5437
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/savepoints:4223
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/sqla_1.50_compat:5321
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/storage-ms-access:4142
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/storage-tweaks:6262
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/subclassed_rsset:5930
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/subquery:5617
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/sybase:5651
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/sybase_mssql:6125
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/versioned_enhancements:4125
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/versioning:4578
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/views:5585
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/trunk:6298
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-C3:318
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-current:2222
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-joins:173
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-resultset:570
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/datetime:1716
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/find_compat:1855
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/find_unique_query_fixes:2142
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/inflate:1988
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/many_to_many:2025
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/re_refactor_bugfix:1944
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/reorganize_tests:1827
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/resultset-new-refactor:1766
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/resultset_2_electric_boogaloo:2175
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/resultset_cleanup:2102
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/sqlt_tests_refactor:2043
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/trunk/DBIx-Class:3606
fe160bb6-dc1c-0410-9f2b-d64a711b54a5:/local/DBIC-trunk-0.08:10510
Modified: DBIx-Class/0.08/branches/joined_count/lib/DBIx/Class/SQLAHacks.pm
===================================================================
--- DBIx-Class/0.08/branches/joined_count/lib/DBIx/Class/SQLAHacks.pm 2009-05-18 16:16:44 UTC (rev 6298)
+++ DBIx-Class/0.08/branches/joined_count/lib/DBIx/Class/SQLAHacks.pm 2009-05-18 17:27:38 UTC (rev 6299)
@@ -256,9 +256,38 @@
sub _order_directions {
my ($self, $order) = @_;
$order = $order->{order_by} if ref $order eq 'HASH';
+ if (ref $order eq 'HASH') {
+ $order = [$self->_order_directions_hash($order)];
+ } elsif (ref $order eq 'ARRAY') {
+ $order = [map {
+ if (ref $_ eq 'HASH') {
+ $self->_order_directions_hash($_);
+ } else {
+ $_;
+ }
+ } @{ $order }];
+ }
return $self->SUPER::_order_directions($order);
}
+sub _order_directions_hash {
+ my ($self, $order) = @_;
+ if (grep { $_ =~ /^-(desc|asc)/i } keys %{$order}) {
+ return map {
+ my $key = $_;
+ my @tmp;
+ s/^-(desc|asc)/\1/i;
+ my $dir = $_;
+ if (ref $order->{ $key } eq 'ARRAY') {
+ @tmp = map "$_ $dir", @{ $order->{ $key } };
+ } else { # should be scalar
+ @tmp = ( "$order->{$key} $dir" );
+ }
+ @tmp;
+ } keys %{$order};
+ }
+}
+
sub _table {
my ($self, $from) = @_;
if (ref $from eq 'ARRAY') {
Modified: DBIx-Class/0.08/branches/joined_count/t/42toplimit.t
===================================================================
--- DBIx-Class/0.08/branches/joined_count/t/42toplimit.t 2009-05-18 16:16:44 UTC (rev 6298)
+++ DBIx-Class/0.08/branches/joined_count/t/42toplimit.t 2009-05-18 17:27:38 UTC (rev 6299)
@@ -5,24 +5,41 @@
use DBIx::Class::Storage::DBI;
use lib qw(t/lib);
use DBICTest; # do not remove even though it is not used
+use DBIC::SqlMakerTest;
-plan tests => 1;
+plan tests => 8;
my $sa = new DBIx::Class::SQLAHacks;
-
$sa->limit_dialect( 'Top' );
-is(
- $sa->select( 'rubbish', [ 'foo.id', 'bar.id' ], undef, { order_by => 'artistid' }, 1, 3 ),
- 'SELECT * FROM
-(
- SELECT TOP 1 * FROM
- (
- SELECT TOP 4 foo.id, bar.id FROM rubbish ORDER BY artistid ASC
- ) AS foo
- ORDER BY artistid DESC
-) AS bar
-ORDER BY artistid ASC
-',
- "make sure limit_dialect( 'Top' ) is working okay"
-);
+sub test_order {
+ my $args = shift;
+ my $order_by = $args->{order_by};
+ my $expected_sql_order = $args->{expected_sql_order};
+
+ my $query = $sa->select( 'foo', [qw{bar baz}], undef, {
+ order_by => $order_by,
+ }, 1, 3
+ );
+ is_same_sql(
+ $query,
+ "SELECT * FROM ( SELECT TOP 1 * FROM ( SELECT TOP 4 bar,baz FROM foo ORDER BY $expected_sql_order->[0] ) AS foo ORDER BY $expected_sql_order->[1] ) AS bar ORDER BY $expected_sql_order->[0]",
+ );
+}
+
+ test_order({ order_by => \'foo DESC' , expected_sql_order => [ 'foo DESC', 'foo ASC' ] });
+ test_order({ order_by => 'foo' , expected_sql_order => [ 'foo ASC', 'foo DESC'] });
+ test_order({ order_by => [ qw{ foo bar} ], expected_sql_order => [ 'foo ASC,bar ASC', 'foo DESC, bar DESC']});
+ test_order({ order_by => { -asc => 'foo' }, expected_sql_order => [ 'foo ASC', 'foo DESC' ] });
+ test_order({ order_by => { -desc => 'foo' }, expected_sql_order => [ 'foo DESC', 'foo ASC' ] });
+
+ test_order({ order_by => ['foo', { -desc => 'bar' } ], expected_sql_order => [ 'foo ASC, bar DESC', 'foo DESC, bar ASC'] });
+ test_order({ order_by => {-asc => [qw{ foo bar }] }, expected_sql_order => ['foo ASC, bar ASC', 'foo DESC, bar DESC' ] });
+ test_order({ order_by =>
+ [
+ { -asc => 'foo' },
+ { -desc => [qw{bar}] },
+ { -asc => [qw{baz frew}]},
+ ],
+ expected_sql_order => ['foo ASC, bar DESC, baz ASC, frew ASC', 'foo DESC, bar ASC, baz DESC, frew DESC']
+ });
Modified: DBIx-Class/0.08/branches/joined_count/t/lib/DBIC/SqlMakerTest.pm
===================================================================
--- DBIx-Class/0.08/branches/joined_count/t/lib/DBIC/SqlMakerTest.pm 2009-05-18 16:16:44 UTC (rev 6298)
+++ DBIx-Class/0.08/branches/joined_count/t/lib/DBIC/SqlMakerTest.pm 2009-05-18 17:27:38 UTC (rev 6299)
@@ -3,145 +3,53 @@
use strict;
use warnings;
-use base qw/Test::Builder::Module Exporter/;
+use base qw/Exporter/;
+use Carp;
+use SQL::Abstract::Test;
+
our @EXPORT = qw/
- &is_same_sql_bind
- &is_same_sql
- &is_same_bind
- &eq_sql
- &eq_bind
- &eq_sql_bind
+ is_same_sql_bind
+ is_same_sql
+ is_same_bind
/;
+our @EXPORT_OK = qw/
+ eq_sql
+ eq_bind
+ eq_sql_bind
+/;
+sub is_same_sql_bind {
+ # unroll possible as_query arrayrefrefs
+ my @args;
-{
- package DBIC::SqlMakerTest::SQLATest;
+ for (1,2) {
+ my $chunk = shift @_;
- # replacement for SQL::Abstract::Test if not available
-
- use strict;
- use warnings;
-
- use base qw/Test::Builder::Module Exporter/;
-
- use Scalar::Util qw(looks_like_number blessed reftype);
- use Data::Dumper;
- use Test::Builder;
- use Test::Deep qw(eq_deeply);
-
- our $tb = __PACKAGE__->builder;
-
- sub is_same_sql_bind
- {
- my ($sql1, $bind_ref1, $sql2, $bind_ref2, $msg) = @_;
-
- my $same_sql = eq_sql($sql1, $sql2);
- my $same_bind = eq_bind($bind_ref1, $bind_ref2);
-
- $tb->ok($same_sql && $same_bind, $msg);
-
- if (!$same_sql) {
- _sql_differ_diag($sql1, $sql2);
+ if ( ref $chunk eq 'REF' and ref $$chunk eq 'ARRAY' ) {
+ my ($sql, @bind) = @$$chunk;
+ push @args, ($sql, \@bind);
}
- if (!$same_bind) {
- _bind_differ_diag($bind_ref1, $bind_ref2);
+ else {
+ push @args, $chunk, shift @_;
}
- }
- sub is_same_sql
- {
- my ($sql1, $sql2, $msg) = @_;
-
- my $same_sql = eq_sql($sql1, $sql2);
-
- $tb->ok($same_sql, $msg);
-
- if (!$same_sql) {
- _sql_differ_diag($sql1, $sql2);
- }
}
- sub is_same_bind
- {
- my ($bind_ref1, $bind_ref2, $msg) = @_;
+ push @args, shift @_;
- my $same_bind = eq_bind($bind_ref1, $bind_ref2);
+ croak "Unexpected argument(s) supplied to is_same_sql_bind: " . join ('; ', @_)
+ if @_;
- $tb->ok($same_bind, $msg);
-
- if (!$same_bind) {
- _bind_differ_diag($bind_ref1, $bind_ref2);
- }
- }
-
- sub _sql_differ_diag
- {
- my ($sql1, $sql2) = @_;
-
- $tb->diag("SQL expressions differ\n"
- . " got: $sql1\n"
- . "expected: $sql2\n"
- );
- }
-
- sub _bind_differ_diag
- {
- my ($bind_ref1, $bind_ref2) = @_;
-
- $tb->diag("BIND values differ\n"
- . " got: " . Dumper($bind_ref1)
- . "expected: " . Dumper($bind_ref2)
- );
- }
-
- sub eq_sql
- {
- my ($left, $right) = @_;
-
- $left =~ s/\s+//g;
- $right =~ s/\s+//g;
-
- return $left eq $right;
- }
-
- sub eq_bind
- {
- my ($bind_ref1, $bind_ref2) = @_;
-
- return eq_deeply($bind_ref1, $bind_ref2);
- }
-
- sub eq_sql_bind
- {
- my ($sql1, $bind_ref1, $sql2, $bind_ref2) = @_;
-
- return eq_sql($sql1, $sql2) && eq_bind($bind_ref1, $bind_ref2);
- }
+ SQL::Abstract::Test::is_same_sql_bind (@args);
}
-eval "use SQL::Abstract::Test;";
-if ($@ eq '') {
- # SQL::Abstract::Test available
+*is_same_sql = \&SQL::Abstract::Test::is_same_sql;
+*is_same_bind = \&SQL::Abstract::Test::is_same_bind;
+*eq_sql = \&SQL::Abstract::Test::eq_sql;
+*eq_bind = \&SQL::Abstract::Test::eq_bind;
+*eq_sql_bind = \&SQL::Abstract::Test::eq_sql_bind;
- *is_same_sql_bind = \&SQL::Abstract::Test::is_same_sql_bind;
- *is_same_sql = \&SQL::Abstract::Test::is_same_sql;
- *is_same_bind = \&SQL::Abstract::Test::is_same_bind;
- *eq_sql = \&SQL::Abstract::Test::eq_sql;
- *eq_bind = \&SQL::Abstract::Test::eq_bind;
- *eq_sql_bind = \&SQL::Abstract::Test::eq_sql_bind;
-} else {
- # old SQL::Abstract
-
- *is_same_sql_bind = \&DBIC::SqlMakerTest::SQLATest::is_same_sql_bind;
- *is_same_sql = \&DBIC::SqlMakerTest::SQLATest::is_same_sql;
- *is_same_bind = \&DBIC::SqlMakerTest::SQLATest::is_same_bind;
- *eq_sql = \&DBIC::SqlMakerTest::SQLATest::eq_sql;
- *eq_bind = \&DBIC::SqlMakerTest::SQLATest::eq_bind;
- *eq_sql_bind = \&DBIC::SqlMakerTest::SQLATest::eq_sql_bind;
-}
-
-
1;
__END__
@@ -167,23 +75,31 @@
Exports functions that can be used to compare generated SQL and bind values.
-If L<SQL::Abstract::Test> (packaged in L<SQL::Abstract> versions 1.50 and
-above) is available, then it is used to perform the comparisons (all functions
-are delegated to id). Otherwise uses simple string comparison for the SQL
-statements and simple L<Data::Dumper>-like recursive stringification for
-comparison of bind values.
+This is a thin wrapper around L<SQL::Abstract::Test>, which makes it easier
+to compare as_query sql/bind arrayrefrefs directly.
-
=head1 FUNCTIONS
=head2 is_same_sql_bind
is_same_sql_bind(
- $given_sql, \@given_bind,
+ $given_sql, \@given_bind,
$expected_sql, \@expected_bind,
$test_msg
);
+ is_same_sql_bind(
+ $rs->as_query
+ $expected_sql, \@expected_bind,
+ $test_msg
+ );
+
+ is_same_sql_bind(
+ \[$given_sql, @given_bind],
+ $expected_sql, \@expected_bind,
+ $test_msg
+ );
+
Compares given and expected pairs of C<($sql, \@bind)>, and calls
L<Test::Builder/ok> on the result, with C<$test_msg> as message.
@@ -245,4 +161,4 @@
Copyright 2008 by Norbert Buchmuller.
This library is free software; you can redistribute it and/or modify
-it under the same terms as Perl itself.
+it under the same terms as Perl itself.
More information about the Bast-commits
mailing list