POD'd result_class func
[dbsrgits/DBIx-Class.git] / t / 19quotes_newstyle.t
CommitLineData
2cc3a7be 1use strict;
2use warnings;
3
4use Test::More;
5use IO::File;
6
7BEGIN {
8 eval "use DBD::SQLite";
9 plan $@
10 ? ( skip_all => 'needs DBD::SQLite for testing' )
11 : ( tests => 6 );
12}
13
14use lib qw(t/lib);
15
16use_ok('DBICTest');
17DBICTest->init_schema();
18
19my $dsn = DBICTest->schema->storage->connect_info->[0];
20
21DBICTest->schema->connection($dsn, { quote_char => "'", name_sep => '.' });
22
23my $rs = DBICTest::CD->search(
24 { 'me.year' => 2001, 'artist.name' => 'Caterwauler McCrae' },
25 { join => 'artist' });
26
27cmp_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
38my $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
49DBICTest->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' });
54cmp_ok($rs->count,'==', 1,"join quoted with brackets.");
55
56my %data = (
57 name => 'Bill',
58 order => '12'
59);
60
61DBICTest->schema->connection($dsn, { quote_char => '`', name_sep => '.' });
62
63cmp_ok(DBICTest->schema->storage->sql_maker->update('group', \%data), 'eq', 'UPDATE `group` SET `name` = ?, `order` = ?', "quoted table names for UPDATE");
64