8 my $schema = DBICTest->init_schema();
12 ok ( $schema->storage->debug(1), 'debug' );
14 $schema->storage->debugfh(
15 IO::File->new('t/var/sql.log', 'w')
21 my $rs = $schema->resultset('CD')->search({});
24 my $log = new IO::File('t/var/sql.log', 'r') or die($!);
27 ok($line =~ /^SELECT COUNT/, 'Log success');
29 $schema->storage->debugfh(undef);
30 $ENV{'DBIC_TRACE'} = '=t/var/foo.log';
31 $rs = $schema->resultset('CD')->search({});
33 $log = new IO::File('t/var/foo.log', 'r') or die($!);
36 ok($line =~ /^SELECT COUNT/, 'Log success');
38 $schema->storage->debugobj->debugfh(undef);
39 delete($ENV{'DBIC_TRACE'});
40 open(STDERRCOPY, '>&STDERR');
41 stat(STDERRCOPY); # nop to get warnings quiet
44 $rs = $schema->resultset('CD')->search({});
47 ok($@, 'Died on closed FH');
48 open(STDERR, '>&STDERRCOPY');
50 # test trace output correctness for bind params
53 $schema->storage->debugcb( sub { $sql = $_[1] } );
55 my @cds = $schema->resultset('CD')->search( { artist => 1, cdid => { -between => [ 1, 3 ] }, } );
58 qr/\QSELECT me.cdid, me.artist, me.title, me.year FROM cd me WHERE ( artist = ? AND cdid BETWEEN ? AND ? ): '1', '1', '3'\E/,
59 'got correct SQL with all bind parameters'