X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F19quotes_newstyle.t;h=02c145070649cfd91d80acd6d1786da53b3a5109;hb=8206c013c33230647783d08fa5635d59f2d0893a;hp=31feaa30021e357f249e7f00f9b88b5998c30db1;hpb=5a1f2d730c2ce5d0b7e8b996ffaa529c4872b410;p=dbsrgits%2FDBIx-Class.git diff --git a/t/19quotes_newstyle.t b/t/19quotes_newstyle.t index 31feaa3..02c1450 100644 --- a/t/19quotes_newstyle.t +++ b/t/19quotes_newstyle.t @@ -14,44 +14,55 @@ BEGIN { use lib qw(t/lib); use_ok('DBICTest'); -DBICTest->init_schema(); +my $schema = DBICTest->init_schema(); -my $orig_debugcb = DBICTest->schema->storage->debugcb; -my $orig_debug = DBICTest->schema->storage->debug; +my $orig_debugcb = $schema->storage->debugcb; +my $orig_debug = $schema->storage->debug; -diag('Testing against ' . join(' ', map { DBICTest->schema->storage->dbh->get_info($_) } qw/17 18/)); +diag('Testing against ' . join(' ', map { $schema->storage->dbh->get_info($_) } qw/17 18/)); -my $dsn = DBICTest->schema->storage->connect_info->[0]; -DBICTest->schema->connection($dsn, { quote_char => '`', name_sep => '.' }); +my $dsn = $schema->storage->connect_info->[0]; +$schema->connection( + $dsn, + undef, + undef, + { AutoCommit => 1 }, + { quote_char => '`', name_sep => '.' }, +); my $sql = ''; -DBICTest->schema->storage->debugcb(sub { $sql = $_[1] }); -DBICTest->schema->storage->debug(1); +$schema->storage->debugcb(sub { $sql = $_[1] }); +$schema->storage->debug(1); my $rs; -$rs = DBICTest::CD->search( +$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 quoting'); my $order = 'year DESC'; -$rs = DBICTest::CD->search({}, +$rs = $schema->resultset('CD')->search({}, { 'order_by' => $order }); eval { $rs->first }; like($sql, qr/ORDER BY `\Q${order}\E`/, 'quoted ORDER BY with DESC (should use a scalarref anyway)'); -$rs = DBICTest::CD->search({}, +$rs = $schema->resultset('CD')->search({}, { 'order_by' => \$order }); eval { $rs->first }; like($sql, qr/ORDER BY \Q${order}\E/, 'did not quote ORDER BY with scalarref'); -DBICTest->schema->connection($dsn, { quote_char => [qw/[ ]/], name_sep => '.' }); -DBICTest->schema->storage->debugcb(sub { $sql = $_[1] }); -DBICTest->schema->storage->debug(1); +$schema->connection( + $dsn, + undef, + undef, + { AutoCommit => 1, quote_char => [qw/[ ]/], name_sep => '.' } +); +$schema->storage->debugcb(sub { $sql = $_[1] }); +$schema->storage->debug(1); -$rs = DBICTest::CD->search( +$rs = $schema->resultset('CD')->search( { 'me.year' => 2001, 'artist.name' => 'Caterwauler McCrae' }, { join => 'artist' }); eval { $rs->count }; @@ -62,9 +73,14 @@ my %data = ( order => '12' ); -DBICTest->schema->connection($dsn, { quote_char => '`', name_sep => '.' }); +$schema->connection( + $dsn, + undef, + undef, + { AutoCommit => 1, quote_char => '`', name_sep => '.' } +); -is(DBICTest->schema->storage->sql_maker->update('group', \%data), 'UPDATE `group` SET `name` = ?, `order` = ?', 'quoted table names for UPDATE'); +is($schema->storage->sql_maker->update('group', \%data), 'UPDATE `group` SET `name` = ?, `order` = ?', 'quoted table names for UPDATE'); -DBICTest->schema->storage->debugcb($orig_debugcb); -DBICTest->schema->storage->debug($orig_debug); +$schema->storage->debugcb($orig_debugcb); +$schema->storage->debug($orig_debug);