[Bast-commits] r5094 - in DBIx-Class/0.08/branches/sqla_1.50_compat: . lib/DBIx/Class/Storage t t/lib/DBICTest

norbi at dev.catalyst.perl.org norbi at dev.catalyst.perl.org
Mon Nov 10 23:04:34 GMT 2008


Author: norbi
Date: 2008-11-10 23:04:34 +0000 (Mon, 10 Nov 2008)
New Revision: 5094

Added:
   DBIx-Class/0.08/branches/sqla_1.50_compat/t/lib/DBICTest/DBICDebugObj.pm
Modified:
   DBIx-Class/0.08/branches/sqla_1.50_compat/
   DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class/Storage/DBI.pm
   DBIx-Class/0.08/branches/sqla_1.50_compat/t/19quotes.t
   DBIx-Class/0.08/branches/sqla_1.50_compat/t/19quotes_newstyle.t
   DBIx-Class/0.08/branches/sqla_1.50_compat/t/41orrible.t
   DBIx-Class/0.08/branches/sqla_1.50_compat/t/76joins.t
   DBIx-Class/0.08/branches/sqla_1.50_compat/t/91debug.t
   DBIx-Class/0.08/branches/sqla_1.50_compat/t/95sql_maker_quote.t
   DBIx-Class/0.08/branches/sqla_1.50_compat/t/99dbic_sqlt_parser.t
Log:
 r5094 at vger:  mendel | 2008-11-10 23:59:32 +0100
  * Converted some of the test cases to use SQL::Abstract::Test.
  * Added the parens for the join condition (SQL::Abstract::Test can't cope with it, and, besides, they help readability there; plus this gives the same output that older SQLA generated).



Property changes on: DBIx-Class/0.08/branches/sqla_1.50_compat
___________________________________________________________________
Name: svk:merge
   - 168d5346-440b-0410-b799-f706be625ff1:/DBIx-Class-current:2207
462d4d0c-b505-0410-bf8e-ce8f877b3390:/local/bast/DBIx-Class:3159
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
bd5ac9a7-f185-4d95-9186-dbb8b392a572:/local/os/bast/DBIx-Class/0.08/trunk:2798
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/cdbicompat_integration:4160
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/complex_join_rels:4589
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/file_column:3920
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_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/replication_dedux:4600
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/savepoints:4223
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/storage-ms-access:4142
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:/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/sqla_1.50_compat:5094
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
bd5ac9a7-f185-4d95-9186-dbb8b392a572:/local/os/bast/DBIx-Class/0.08/trunk:2798
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/cdbicompat_integration:4160
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/complex_join_rels:4589
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/file_column:3920
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_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/replication_dedux:4600
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/savepoints:4223
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/storage-ms-access:4142
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:/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/sqla_1.50_compat/lib/DBIx/Class/Storage/DBI.pm
===================================================================
--- DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class/Storage/DBI.pm	2008-11-10 23:04:10 UTC (rev 5093)
+++ DBIx-Class/0.08/branches/sqla_1.50_compat/lib/DBIx/Class/Storage/DBI.pm	2008-11-10 23:04:34 UTC (rev 5094)
@@ -237,7 +237,7 @@
     } else {
       push(@sqlf, $self->_make_as($to));
     }
-    push(@sqlf, ' ON ', $self->_join_condition($on));
+    push(@sqlf, ' ON (', $self->_join_condition($on), ')');
   }
   return join('', @sqlf);
 }

Modified: DBIx-Class/0.08/branches/sqla_1.50_compat/t/19quotes.t
===================================================================
--- DBIx-Class/0.08/branches/sqla_1.50_compat/t/19quotes.t	2008-11-10 23:04:10 UTC (rev 5093)
+++ DBIx-Class/0.08/branches/sqla_1.50_compat/t/19quotes.t	2008-11-10 23:04:34 UTC (rev 5094)
@@ -3,30 +3,28 @@
 
 use Test::More;
 use IO::File;
+use SQL::Abstract::Test import => ['is_same_sql_bind'];
 
 BEGIN {
     eval "use DBD::SQLite";
     plan $@
         ? ( skip_all => 'needs DBD::SQLite for testing' )
-        : ( tests => 6 );
+        : ( tests => 7 );
 }
 
 use lib qw(t/lib);
 
 use_ok('DBICTest');
+use_ok('DBICTest::DBICDebugObj');
 my $schema = DBICTest->init_schema();
 
-my $orig_debugcb = $schema->storage->debugcb;
-my $orig_debug = $schema->storage->debug;
-
 diag('Testing against ' . join(' ', map { $schema->storage->dbh->get_info($_) } qw/17 18/));
 
 $schema->storage->sql_maker->quote_char('`');
 $schema->storage->sql_maker->name_sep('.');
 
-my $sql = '';
-
-$schema->storage->debugcb(sub { $sql = $_[1] });
+my ($sql, @bind) = ('');
+$schema->storage->debugobj(DBICTest::DBICDebugObj->new(\$sql, \@bind));
 $schema->storage->debug(1);
 
 my $rs;
@@ -35,7 +33,11 @@
            { 'me.year' => 2001, 'artist.name' => 'Caterwauler McCrae' },
            { join => 'artist' });
 eval { $rs->count };
-like($sql, qr/\QSELECT COUNT( * ) FROM `cd` `me`  JOIN `artist` `artist` ON ( `artist`.`artistid` = `me`.`artist` ) WHERE ( `artist`.`name` = ? AND `me`.`year` = ? )\E/, 'got correct SQL for count query with quoting');
+is_same_sql_bind(
+  $sql, \@bind,
+  "SELECT COUNT( * ) FROM `cd` `me`  JOIN `artist` `artist` ON ( `artist`.`artistid` = `me`.`artist` ) WHERE ( `artist`.`name` = ? AND `me`.`year` = ? )", ["'Caterwauler McCrae'", "'2001'"],
+  'got correct SQL for count query with quoting'
+);
 
 my $order = 'year DESC';
 $rs = $schema->resultset('CD')->search({},
@@ -55,7 +57,11 @@
            { 'me.year' => 2001, 'artist.name' => 'Caterwauler McCrae' },
            { join => 'artist' });
 eval { $rs->count };
-like($sql, qr/\QSELECT COUNT( * ) FROM [cd] [me]  JOIN [artist] [artist] ON ( [artist].[artistid] = [me].[artist] ) WHERE ( [artist].[name] = ? AND [me].[year] = ? )\E/, 'got correct SQL for count query with bracket quoting');
+is_same_sql_bind(
+  $sql, \@bind,
+  "SELECT COUNT( * ) FROM [cd] [me]  JOIN [artist] [artist] ON ( [artist].[artistid] = [me].[artist] ) WHERE ( [artist].[name] = ? AND [me].[year] = ? )", ["'Caterwauler McCrae'", "'2001'"],
+  'got correct SQL for count query with bracket quoting'
+);
 
 my %data = (
        name => 'Bill',
@@ -66,6 +72,3 @@
 $schema->storage->sql_maker->name_sep('.');
 
 is($schema->storage->sql_maker->update('group', \%data), 'UPDATE `group` SET `name` = ?, `order` = ?', 'quoted table names for UPDATE');
-
-$schema->storage->debugcb($orig_debugcb);
-$schema->storage->debug($orig_debug);

Modified: DBIx-Class/0.08/branches/sqla_1.50_compat/t/19quotes_newstyle.t
===================================================================
--- DBIx-Class/0.08/branches/sqla_1.50_compat/t/19quotes_newstyle.t	2008-11-10 23:04:10 UTC (rev 5093)
+++ DBIx-Class/0.08/branches/sqla_1.50_compat/t/19quotes_newstyle.t	2008-11-10 23:04:34 UTC (rev 5094)
@@ -3,22 +3,22 @@
 
 use Test::More;
 use IO::File;
+use SQL::Abstract::Test import => ['is_same_sql_bind'];
 
 BEGIN {
     eval "use DBD::SQLite";
     plan $@
         ? ( skip_all => 'needs DBD::SQLite for testing' )
-        : ( tests => 6 );
+        : ( tests => 7 );
 }
 
 use lib qw(t/lib);
 
 use_ok('DBICTest');
+use_ok('DBICTest::DBICDebugObj');
+
 my $schema = DBICTest->init_schema();
 
-my $orig_debugcb = $schema->storage->debugcb;
-my $orig_debug = $schema->storage->debug;
-
 diag('Testing against ' . join(' ', map { $schema->storage->dbh->get_info($_) } qw/17 18/));
 
 my $dsn = $schema->storage->_dbi_connect_info->[0];
@@ -30,8 +30,8 @@
   { quote_char => '`', name_sep => '.' },
 );
 
-my $sql = '';
-$schema->storage->debugcb(sub { $sql = $_[1] });
+my ($sql, @bind) = ('');
+$schema->storage->debugobj(DBICTest::DBICDebugObj->new(\$sql, \@bind)),
 $schema->storage->debug(1);
 
 my $rs;
@@ -40,7 +40,11 @@
            { 'me.year' => 2001, 'artist.name' => 'Caterwauler McCrae' },
            { join => 'artist' });
 eval { $rs->count };
-like($sql, qr/\QSELECT COUNT( * ) FROM `cd` `me`  JOIN `artist` `artist` ON ( `artist`.`artistid` = `me`.`artist` ) WHERE ( `artist`.`name` = ? AND `me`.`year` = ? )\E/, 'got correct SQL for count query with quoting');
+is_same_sql_bind(
+  $sql, \@bind,
+  "SELECT COUNT( * ) FROM `cd` `me`  JOIN `artist` `artist` ON ( `artist`.`artistid` = `me`.`artist` ) WHERE ( `artist`.`name` = ? AND `me`.`year` = ? )", ["'Caterwauler McCrae'", "'2001'"],
+  'got correct SQL for count query with quoting'
+);
 
 my $order = 'year DESC';
 $rs = $schema->resultset('CD')->search({},
@@ -59,14 +63,19 @@
   undef,
   { AutoCommit => 1, quote_char => [qw/[ ]/], name_sep => '.' }
 );
-$schema->storage->debugcb(sub { $sql = $_[1] });
+
+$schema->storage->debugobj(DBICTest::DBICDebugObj->new(\$sql, \@bind)),
 $schema->storage->debug(1);
 
 $rs = $schema->resultset('CD')->search(
            { 'me.year' => 2001, 'artist.name' => 'Caterwauler McCrae' },
            { join => 'artist' });
 eval { $rs->count };
-like($sql, qr/\QSELECT COUNT( * ) FROM [cd] [me]  JOIN [artist] [artist] ON ( [artist].[artistid] = [me].[artist] ) WHERE ( [artist].[name] = ? AND [me].[year] = ? )\E/, 'got correct SQL for count query with bracket quoting');
+is_same_sql_bind(
+  $sql, \@bind,
+  "SELECT COUNT( * ) FROM [cd] [me]  JOIN [artist] [artist] ON ( [artist].[artistid] = [me].[artist] ) WHERE ( [artist].[name] = ? AND [me].[year] = ? )", ["'Caterwauler McCrae'", "'2001'"],
+  'got correct SQL for count query with bracket quoting'
+);
 
 my %data = (
        name => 'Bill',
@@ -81,6 +90,3 @@
 );
 
 is($schema->storage->sql_maker->update('group', \%data), 'UPDATE `group` SET `name` = ?, `order` = ?', 'quoted table names for UPDATE');
-
-$schema->storage->debugcb($orig_debugcb);
-$schema->storage->debug($orig_debug);

Modified: DBIx-Class/0.08/branches/sqla_1.50_compat/t/41orrible.t
===================================================================
--- DBIx-Class/0.08/branches/sqla_1.50_compat/t/41orrible.t	2008-11-10 23:04:10 UTC (rev 5093)
+++ DBIx-Class/0.08/branches/sqla_1.50_compat/t/41orrible.t	2008-11-10 23:04:34 UTC (rev 5094)
@@ -3,6 +3,7 @@
 
 use Test::More;
 #use DBIx::Class::Storage::DBI;
+use SQL::Abstract::Test import => ['is_same_sql_bind'];
 use DBIx::Class::Storage::DBI::Oracle::WhereJoins;
 
 plan tests => 4;
@@ -29,7 +30,8 @@
 # search with undefined or empty $cond
 
 #  my ($self, $table, $fields, $where, $order, @rest) = @_;
-is($sa->select([
+my ($sql, @bind) = $sa->select(
+    [
         { me => "cd" },
         [
             { "-join_type" => "LEFT", artist => "artist" },
@@ -38,10 +40,16 @@
     ],
     [ 'cd.cdid', 'cd.artist', 'cd.title', 'cd.year', 'artist.artistid', 'artist.name' ],
     undef,
-    undef),
-   'SELECT cd.cdid, cd.artist, cd.title, cd.year, artist.artistid, artist.name FROM cd me, artist artist WHERE ( artist.artistid(+) = me.artist )', 'WhereJoins search with empty where clause');
+    undef
+);
+is_same_sql_bind(
+  $sql, \@bind,
+  'SELECT cd.cdid, cd.artist, cd.title, cd.year, artist.artistid, artist.name FROM cd me, artist artist WHERE ( artist.artistid(+) = me.artist )', [],
+  'WhereJoins search with empty where clause'
+);
 
-is($sa->select([
+($sql, @bind) = $sa->select(
+    [
         { me => "cd" },
         [
             { "-join_type" => "", artist => "artist" },
@@ -50,10 +58,16 @@
     ],
     [ 'cd.cdid', 'cd.artist', 'cd.title', 'cd.year', 'artist.artistid', 'artist.name' ],
     { 'artist.artistid' => 3 },
-    undef),
-   'SELECT cd.cdid, cd.artist, cd.title, cd.year, artist.artistid, artist.name FROM cd me, artist artist WHERE ( ( ( artist.artistid = me.artist ) AND ( artist.artistid = ? ) ) )', 'WhereJoins search with where clause');
+    undef
+);
+is_same_sql_bind(
+  $sql, \@bind,
+  'SELECT cd.cdid, cd.artist, cd.title, cd.year, artist.artistid, artist.name FROM cd me, artist artist WHERE ( ( ( artist.artistid = me.artist ) AND ( artist.artistid = ? ) ) )', [3],
+  'WhereJoins search with where clause'
+);
 
-is($sa->select([
+($sql, @bind) = $sa->select(
+    [
         { me => "cd" },
         [
             { "-join_type" => "LEFT", artist => "artist" },
@@ -62,7 +76,12 @@
     ],
     [ 'cd.cdid', 'cd.artist', 'cd.title', 'cd.year', 'artist.artistid', 'artist.name' ],
     [{ 'artist.artistid' => 3 }, { 'me.cdid' => 5 }],
-    undef),
-   'SELECT cd.cdid, cd.artist, cd.title, cd.year, artist.artistid, artist.name FROM cd me, artist artist WHERE ( ( ( artist.artistid(+) = me.artist ) AND ( ( ( artist.artistid = ? ) OR ( me.cdid = ? ) ) ) ) )', 'WhereJoins search with or in where clause');
+    undef
+);
+is_same_sql_bind(
+  $sql, \@bind,
+  'SELECT cd.cdid, cd.artist, cd.title, cd.year, artist.artistid, artist.name FROM cd me, artist artist WHERE ( ( ( artist.artistid(+) = me.artist ) AND ( ( ( artist.artistid = ? ) OR ( me.cdid = ? ) ) ) ) )', [3, 5],
+  'WhereJoins search with or in where clause'
+);
 
 

Modified: DBIx-Class/0.08/branches/sqla_1.50_compat/t/76joins.t
===================================================================
--- DBIx-Class/0.08/branches/sqla_1.50_compat/t/76joins.t	2008-11-10 23:04:10 UTC (rev 5093)
+++ DBIx-Class/0.08/branches/sqla_1.50_compat/t/76joins.t	2008-11-10 23:04:34 UTC (rev 5094)
@@ -5,6 +5,7 @@
 use lib qw(t/lib);
 use DBICTest;
 use Data::Dumper;
+use SQL::Abstract::Test import => ['is_same_sql_bind'];
 
 my $schema = DBICTest->init_schema();
 
@@ -43,7 +44,11 @@
           . 'child.father_id ) JOIN person mother ON ( mother.person_id '
           . '= child.mother_id )'
           ;
-is( $sa->_recurse_from(@j), $match, 'join 1 ok' );
+is_same_sql_bind(
+  $sa->_recurse_from(@j), [],
+  $match, [],
+  'join 1 ok'
+);
 
 my @j2 = (
     { mother => 'person' },
@@ -59,8 +64,13 @@
        . ' father.person_id = child.father_id )) ON ( mother.person_id = '
        . 'child.mother_id )'
        ;
-is( $sa->_recurse_from(@j2), $match, 'join 2 ok' );
+is_same_sql_bind(
+  $sa->_recurse_from(@j2), [],
+  $match, [],
+  'join 2 ok'
+);
 
+
 my @j3 = (
     { child => 'person' },
     [ { father => 'person', -join_type => 'inner' }, { 'father.person_id' => 'child.father_id' }, ],
@@ -71,7 +81,11 @@
           . '= child.mother_id )'
           ;
 
-is( $sa->_recurse_from(@j3), $match, 'join 3 (inner join) ok');
+is_same_sql_bind(
+  $sa->_recurse_from(@j3), [],
+  $match, [],
+  'join 3 (inner join) ok'
+);
 
 my @j4 = (
     { mother => 'person' },
@@ -87,7 +101,11 @@
        . ' father.person_id = child.father_id )) ON ( mother.person_id = '
        . 'child.mother_id )'
        ;
-is( $sa->_recurse_from(@j4), $match, 'join 4 (nested joins + join types) ok');
+is_same_sql_bind(
+  $sa->_recurse_from(@j4), [],
+  $match, [],
+  'join 4 (nested joins + join types) ok'
+);
 
 my @j5 = (
     { child => 'person' },
@@ -98,7 +116,11 @@
           . 'child.father_id ) JOIN person mother ON ( mother.person_id '
           . '= child.mother_id )'
           ;
-is( $sa->_recurse_from(@j5), $match, 'join 5 (SCALAR reference for ON statement) ok' );
+is_same_sql_bind(
+  $sa->_recurse_from(@j5), [],
+  $match, [],
+  'join 5 (SCALAR reference for ON statement) ok'
+);
 
 my @j6 = (
     { child => 'person' },

Modified: DBIx-Class/0.08/branches/sqla_1.50_compat/t/91debug.t
===================================================================
--- DBIx-Class/0.08/branches/sqla_1.50_compat/t/91debug.t	2008-11-10 23:04:10 UTC (rev 5093)
+++ DBIx-Class/0.08/branches/sqla_1.50_compat/t/91debug.t	2008-11-10 23:04:34 UTC (rev 5094)
@@ -4,10 +4,12 @@
 use Test::More;
 use lib qw(t/lib);
 use DBICTest;
+use DBICTest::DBICDebugObj;
+use SQL::Abstract::Test import => ['is_same_sql_bind'];
 
 my $schema = DBICTest->init_schema();
 
-plan tests => 6;
+plan tests => 7;
 
 ok ( $schema->storage->debug(1), 'debug' );
 ok ( defined(
@@ -49,15 +51,24 @@
 
 # test trace output correctness for bind params
 {
-    my $sql = '';
+    my ($sql, @bind) = ('');
     $schema->storage->debugcb( sub { $sql = $_[1] } );
 
     my @cds = $schema->resultset('CD')->search( { artist => 1, cdid => { -between => [ 1, 3 ] }, } );
-    like(
-        $sql,
-        qr/\QSELECT me.cdid, me.artist, me.title, me.year, me.genreid FROM cd me WHERE ( artist = ? AND cdid BETWEEN ? AND ? ): '1', '1', '3'\E/,
-        'got correct SQL with all bind parameters'
+    is_same_sql_bind(
+        $sql, [],
+        "SELECT me.cdid, me.artist, me.title, me.year, me.genreid FROM cd me WHERE ( artist = ? AND cdid BETWEEN ? AND ? ): '1', '1', '3'", [],
+        'got correct SQL with all bind parameters (debugcb)'
     );
+
+    $schema->storage->debugcb(undef);
+    $schema->storage->debugobj(DBICTest::DBICDebugObj->new(\$sql, \@bind));
+    @cds = $schema->resultset('CD')->search( { artist => 1, cdid => { -between => [ 1, 3 ] }, } );
+    is_same_sql_bind(
+        $sql, \@bind,
+        "SELECT me.cdid, me.artist, me.title, me.year, me.genreid FROM cd me WHERE ( artist = ? AND cdid BETWEEN ? AND ? )", ["'1'", "'1'", "'3'"],
+        'got correct SQL with all bind parameters (debugobj)'
+    );
 }
 
 1;

Modified: DBIx-Class/0.08/branches/sqla_1.50_compat/t/95sql_maker_quote.t
===================================================================
--- DBIx-Class/0.08/branches/sqla_1.50_compat/t/95sql_maker_quote.t	2008-11-10 23:04:10 UTC (rev 5093)
+++ DBIx-Class/0.08/branches/sqla_1.50_compat/t/95sql_maker_quote.t	2008-11-10 23:04:34 UTC (rev 5094)
@@ -2,6 +2,7 @@
 use warnings;
 
 use Test::More;
+use SQL::Abstract::Test import => ['is_same_sql_bind'];
 
 
 BEGIN {
@@ -22,7 +23,7 @@
 $sql_maker->quote_char('`');
 $sql_maker->name_sep('.');
 
-my ($sql,) = $sql_maker->select(
+my ($sql, @bind) = $sql_maker->select(
           [
             {
               'me' => 'cd'
@@ -51,11 +52,13 @@
           undef
 );
 
-is($sql, 
-   q/SELECT COUNT( * ) FROM `cd` `me`  JOIN `artist` `artist` ON ( `artist`.`artistid` = `me`.`artist` ) WHERE ( `artist`.`name` = ? AND `me`.`year` = ? )/, 
-   'got correct SQL for count query with quoting');
+is_same_sql_bind(
+  $sql, \@bind,
+  q/SELECT COUNT( * ) FROM `cd` `me`  JOIN `artist` `artist` ON ( `artist`.`artistid` = `me`.`artist` ) WHERE ( `artist`.`name` = ? AND `me`.`year` = ? )/, [ ['artist.name' => 'Caterwauler McCrae'], ['me.year' => 2001] ],
+  'got correct SQL and bind parameters for count query with quoting'
+);
 
-($sql,) = $sql_maker->select(
+($sql, @bind) = $sql_maker->select(
           [
             {
               'me' => 'cd'
@@ -86,7 +89,7 @@
 TODO: {
     local $TODO = "select attr with star needs fixing (mst/nate)";
 
-    ($sql,) = $sql_maker->select(
+    ($sql, @bind) = $sql_maker->select(
           [
             {
               'me' => 'cd'
@@ -101,10 +104,14 @@
           undef    
     );
 
-    is($sql, q/SELECT `me`.* FROM `cd` `me`/, 'select attr with me.* is right');
+    is_same_sql_bind(
+      $sql, \@bind,
+      q/SELECT `me`.* FROM `cd` `me`/, [],
+      'select attr with me.* is right'
+    );
 }
 
-($sql,) = $sql_maker->select(
+($sql, @bind) = $sql_maker->select(
           [
             {
               'me' => 'cd'
@@ -124,18 +131,13 @@
           undef
 );
 
-is($sql, 
-   q/SELECT `me`.`cdid`, `me`.`artist`, `me`.`title`, `me`.`year` FROM `cd` `me` ORDER BY year DESC/,
-   'did not quote ORDER BY with scalarref');
-
-my %data = ( 
-    name => 'Bill',
-    order => 12
+is_same_sql_bind(
+  $sql, \@bind,
+  q/SELECT `me`.`cdid`, `me`.`artist`, `me`.`title`, `me`.`year` FROM `cd` `me` ORDER BY year DESC/, [],
+  'did not quote ORDER BY with scalarref'
 );
 
-my @binds;
-
-($sql, at binds) = $sql_maker->update(
+($sql, @bind) = $sql_maker->update(
           'group',
           {
             'order' => '12',
@@ -143,13 +145,15 @@
           }
 );
 
-is($sql,
-   q/UPDATE `group` SET `name` = ?, `order` = ?/,
-   'quoted table names for UPDATE');
+is_same_sql_bind(
+  $sql, \@bind,
+  q/UPDATE `group` SET `name` = ?, `order` = ?/, [ ['name' => 'Bill'], ['order' => '12'] ],
+  'quoted table names for UPDATE'
+);
 
 $sql_maker->quote_char([qw/[ ]/]);
 
-($sql,) = $sql_maker->select(
+($sql, @bind) = $sql_maker->select(
           [
             {
               'me' => 'cd'
@@ -178,12 +182,14 @@
           undef
 );
 
-is($sql,
-   q/SELECT COUNT( * ) FROM [cd] [me]  JOIN [artist] [artist] ON ( [artist].[artistid] = [me].[artist] ) WHERE ( [artist].[name] = ? AND [me].[year] = ? )/,
-   'got correct SQL for count query with bracket quoting');
+is_same_sql_bind(
+  $sql, \@bind,
+  q/SELECT COUNT( * ) FROM [cd] [me]  JOIN [artist] [artist] ON ( [artist].[artistid] = [me].[artist] ) WHERE ( [artist].[name] = ? AND [me].[year] = ? )/, [ ['artist.name' => 'Caterwauler McCrae'], ['me.year' => 2001] ],
+  'got correct SQL and bind parameters for count query with bracket quoting'
+);
 
 
-($sql, at binds) = $sql_maker->update(
+($sql, @bind) = $sql_maker->update(
           'group',
           {
             'order' => '12',
@@ -191,6 +197,8 @@
           }
 );
 
-is($sql,
-   q/UPDATE [group] SET [name] = ?, [order] = ?/,
-   'bracket quoted table names for UPDATE');
+is_same_sql_bind(
+  $sql, \@bind,
+  q/UPDATE [group] SET [name] = ?, [order] = ?/, [ ['name' => 'Bill'], ['order' => '12'] ],
+  'bracket quoted table names for UPDATE'
+);

Modified: DBIx-Class/0.08/branches/sqla_1.50_compat/t/99dbic_sqlt_parser.t
===================================================================
--- DBIx-Class/0.08/branches/sqla_1.50_compat/t/99dbic_sqlt_parser.t	2008-11-10 23:04:10 UTC (rev 5093)
+++ DBIx-Class/0.08/branches/sqla_1.50_compat/t/99dbic_sqlt_parser.t	2008-11-10 23:04:34 UTC (rev 5094)
@@ -8,7 +8,7 @@
 BEGIN {
     eval "use DBD::mysql; use SQL::Translator 0.09;";
     plan $@
-        ? ( skip_all => 'needs SQL::Translator 0.09 for testing' )
+        ? ( skip_all => 'needs DBD::mysql and SQL::Translator 0.09 for testing' )
         : ( tests => 102 );
 }
 

Added: DBIx-Class/0.08/branches/sqla_1.50_compat/t/lib/DBICTest/DBICDebugObj.pm
===================================================================
--- DBIx-Class/0.08/branches/sqla_1.50_compat/t/lib/DBICTest/DBICDebugObj.pm	                        (rev 0)
+++ DBIx-Class/0.08/branches/sqla_1.50_compat/t/lib/DBICTest/DBICDebugObj.pm	2008-11-10 23:04:34 UTC (rev 5094)
@@ -0,0 +1,53 @@
+package DBICTest::DBICDebugObj;
+
+use strict;
+use warnings;
+
+use Exporter;
+use Class::C3;
+
+use base qw/DBIx::Class::Storage::Statistics/;
+use base qw/Exporter/;
+use base qw/Class::Accessor::Fast/;
+
+__PACKAGE__->mk_accessors( qw/dbictest_sql_ref dbictest_bind_ref/ );
+
+
+=head2 new(PKG, SQL_REF, BIND_REF, ...)
+
+Creates a new instance that on subsequent queries will store
+the generated SQL to the scalar pointed to by SQL_REF and bind
+values to the array pointed to by BIND_REF.
+
+=cut
+
+sub new {
+  my $pkg = shift;
+  my $sql_ref = shift;
+  my $bind_ref = shift;
+
+  my $self = $pkg->SUPER::new(@_);
+
+  $self->debugfh(undef);
+
+  $self->dbictest_sql_ref($sql_ref);
+  $self->dbictest_bind_ref($bind_ref);
+
+  return $self;
+}
+
+sub query_start {
+  my $self = shift;
+
+  (${$self->dbictest_sql_ref}, @{$self->dbictest_bind_ref}) = @_;
+}
+
+sub query_end { }
+
+sub txn_start { }
+
+sub txn_commit { }
+
+sub txn_rollback { }
+
+1;


Property changes on: DBIx-Class/0.08/branches/sqla_1.50_compat/t/lib/DBICTest/DBICDebugObj.pm
___________________________________________________________________
Name: svn:eol-style
   + native




More information about the Bast-commits mailing list