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