change warning check to death check (new storage exceptions)
[dbsrgits/DBIx-Class.git] / t / 19quotes.t
CommitLineData
2a816814 1use strict;
58d387fe 2use warnings;
3
2a816814 4use Test::More;
5use IO::File;
6
7BEGIN {
8 eval "use DBD::SQLite";
9 plan $@
10 ? ( skip_all => 'needs DBD::SQLite for testing' )
58d387fe 11 : ( tests => 6 );
2a816814 12}
13
14use lib qw(t/lib);
15
16use_ok('DBICTest');
a47e1233 17DBICTest->init_schema();
22b15c96 18
2437a1e3 19DBICTest->schema->storage->sql_maker->quote_char("'");
20DBICTest->schema->storage->sql_maker->name_sep('.');
2a816814 21
22my $rs = DBICTest::CD->search(
54540863 23 { 'me.year' => 2001, 'artist.name' => 'Caterwauler McCrae' },
2a816814 24 { join => 'artist' });
25
26cmp_ok( $rs->count, '==', 1, "join with fields quoted");
27
e535069e 28$rs = DBICTest::CD->search({},
29 { 'order_by' => 'year DESC'});
30{
f11383c2 31 eval{ $rs->first() };
32 like( $@, qr/ORDER BY terms/, "Problem with ORDER BY quotes" );
e535069e 33}
34
35my $order = 'year DESC';
36$rs = DBICTest::CD->search({},
37 { 'order_by' => \$order });
38{
a8e1142c 39 eval { $rs->first() };
40 ok(!$@, "No problem handling ORDER by scalaref" );
e535069e 41}
42
2437a1e3 43DBICTest->schema->storage->sql_maker->quote_char([qw/[ ]/]);
44DBICTest->schema->storage->sql_maker->name_sep('.');
45
46$rs = DBICTest::CD->search(
47 { 'me.year' => 2001, 'artist.name' => 'Caterwauler McCrae' },
48 { join => 'artist' });
49cmp_ok($rs->count,'==', 1,"join quoted with brackets.");
50
6346a152 51my %data = (
52 name => 'Bill',
53 order => '12'
54);
2437a1e3 55
6346a152 56DBICTest->schema->storage->sql_maker->quote_char('`');
57DBICTest->schema->storage->sql_maker->name_sep('.');
2437a1e3 58
6346a152 59cmp_ok(DBICTest->schema->storage->sql_maker->update('group', \%data), 'eq', 'UPDATE `group` SET `name` = ?, `order` = ?', "quoted table names for UPDATE");
2437a1e3 60