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