* Converted some of the test cases to use SQL::Abstract::Test.
[dbsrgits/DBIx-Class.git] / t / 91debug.t
index ae059e4..5314ce4 100644 (file)
@@ -4,10 +4,12 @@ use warnings;
 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,14 +51,23 @@ open(STDERR, '>&STDERRCOPY');
 
 # 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)'
     );
 }