8 use DBICTest ':DiffSQL';
10 my $schema = DBICTest->init_schema(no_deploy => 1);
12 my $sql_maker = $schema->storage->sql_maker;
16 my ($sql, @bind) = $sql_maker->insert(
19 'day' => '2008-11-16',
20 'numbers' => [13, 21, 34, 55, 89]
26 q/INSERT INTO lottery (day, numbers) VALUES (?, ?)/,
27 [ ['day' => '2008-11-16'], ['numbers' => [13, 21, 34, 55, 89]] ],
28 'sql_maker passes arrayrefs in insert'
32 ($sql, @bind) = $sql_maker->update(
35 'day' => '2008-11-16',
36 'numbers' => [13, 21, 34, 55, 89]
42 q/UPDATE lottery SET day = ?, numbers = ?/,
43 [ ['day' => '2008-11-16'], ['numbers' => [13, 21, 34, 55, 89]] ],
44 'sql_maker passes arrayrefs in update'
48 # make sure the cookbook caveat of { $op, \'...' } no longer applies
50 my ($sql, @bind) = $sql_maker->where({
51 last_attempt => \ '< now() - interval "12 hours"',
52 next_attempt => { '<', \ 'now() - interval "12 hours"' },
62 (created <= 1969 OR created > 1984 )
63 AND last_attempt < now() - interval "12 hours"
64 AND next_attempt < now() - interval "12 hours"
70 # Tests base class for => \'FOO' actually generates proper query. for =>
71 # 'READ'|'SHARE' is tested in db-specific subclasses
72 # we have to instantiate base because SQLMaker::SQLite disables _lock_select
74 require DBIx::Class::SQLMaker;
75 my $sa = DBIx::Class::SQLMaker->new;
77 my ($sql, @bind) = $sa->select('foo', '*', {}, { for => 'update' } );
81 'SELECT * FROM foo FOR UPDATE',
87 my ($sql, @bind) = $sa->select('bar', '*', {}, { for => \'baz' } );
91 'SELECT * FROM bar FOR baz',
100 # Make sure the carp/croak override in SQLA works (via SQLMaker)
101 my $file = quotemeta (__FILE__);
103 $schema->resultset ('Artist')->search ({}, { order_by => { -asc => 'stuff', -desc => 'staff' } } )->as_query;
104 }, qr/$file/, 'Exception correctly croak()ed');