X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F19quotes.t;h=ad44bcb55086b3ca0a69b67af0fdc7c5abd651fd;hb=97fec99f26f9bb085051e0472b57cdf81e7fdfb1;hp=79d02eeda61d501d3bed82241c5841cb74230dba;hpb=54540863adce71e931685a37d33e37650e5feb5e;p=dbsrgits%2FDBIx-Class.git diff --git a/t/19quotes.t b/t/19quotes.t index 79d02ee..ad44bcb 100644 --- a/t/19quotes.t +++ b/t/19quotes.t @@ -1,4 +1,6 @@ use strict; +use warnings; + use Test::More; use IO::File; @@ -6,17 +8,16 @@ BEGIN { eval "use DBD::SQLite"; plan $@ ? ( skip_all => 'needs DBD::SQLite for testing' ) - : ( tests => 3 ); + : ( tests => 6 ); } use lib qw(t/lib); use_ok('DBICTest'); +DBICTest->init_schema(); -use_ok('DBICTest::HelperRels'); - -DBICTest::_db->storage->sql_maker->{'quote_char'} = q!'!; -DBICTest::_db->storage->sql_maker->{'name_sep'} = '.'; +DBICTest->schema->storage->sql_maker->quote_char("'"); +DBICTest->schema->storage->sql_maker->name_sep('.'); my $rs = DBICTest::CD->search( { 'me.year' => 2001, 'artist.name' => 'Caterwauler McCrae' }, @@ -24,3 +25,41 @@ my $rs = DBICTest::CD->search( cmp_ok( $rs->count, '==', 1, "join with fields quoted"); +$rs = DBICTest::CD->search({}, + { 'order_by' => 'year DESC'}); +{ + my $warnings = ''; + local $SIG{__WARN__} = sub { $warnings .= $_[0] }; + my $first = eval{ $rs->first() }; + like( $warnings, qr/ORDER BY terms/, "Problem with ORDER BY quotes" ); +} + +my $order = 'year DESC'; +$rs = DBICTest::CD->search({}, + { 'order_by' => \$order }); +{ + my $warnings = ''; + local $SIG{__WARN__} = sub { $warnings .= $_[0] }; + my $first = $rs->first(); + ok( $warnings !~ /ORDER BY terms/, + "No problem handling ORDER by scalaref" ); +} + +DBICTest->schema->storage->sql_maker->quote_char([qw/[ ]/]); +DBICTest->schema->storage->sql_maker->name_sep('.'); + +$rs = DBICTest::CD->search( + { 'me.year' => 2001, 'artist.name' => 'Caterwauler McCrae' }, + { join => 'artist' }); +cmp_ok($rs->count,'==', 1,"join quoted with brackets."); + +my %data = ( + name => 'Bill', + order => '12' +); + +DBICTest->schema->storage->sql_maker->quote_char('`'); +DBICTest->schema->storage->sql_maker->name_sep('.'); + +cmp_ok(DBICTest->schema->storage->sql_maker->update('group', \%data), 'eq', 'UPDATE `group` SET `name` = ?, `order` = ?', "quoted table names for UPDATE"); +