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