1 BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) }
9 use DBICTest ':DiffSQL';
11 my $schema = DBICTest->init_schema(no_deploy => 1);
13 my $sql_maker = $schema->storage->sql_maker;
17 my ($sql, @bind) = $sql_maker->insert(
20 'day' => '2008-11-16',
21 'numbers' => [13, 21, 34, 55, 89]
27 q/INSERT INTO lottery (day, numbers) VALUES (?, ?)/,
28 [ ['day' => '2008-11-16'], ['numbers' => [13, 21, 34, 55, 89]] ],
29 'sql_maker passes arrayrefs in insert'
33 ($sql, @bind) = $sql_maker->update(
36 'day' => '2008-11-16',
37 'numbers' => [13, 21, 34, 55, 89]
43 q/UPDATE lottery SET day = ?, numbers = ?/,
44 [ ['day' => '2008-11-16'], ['numbers' => [13, 21, 34, 55, 89]] ],
45 'sql_maker passes arrayrefs in update'
49 # make sure the cookbook caveat of { $op, \'...' } no longer applies
51 my ($sql, @bind) = $sql_maker->where({
52 last_attempt => \ '< now() - interval "12 hours"',
53 next_attempt => { '<', \ 'now() - interval "12 hours"' },
63 (created <= 1969 OR created > 1984 )
64 AND last_attempt < now() - interval "12 hours"
65 AND next_attempt < now() - interval "12 hours"
71 # Tests base class for => \'FOO' actually generates proper query. for =>
72 # 'READ'|'SHARE' is tested in db-specific subclasses
73 # we have to instantiate base because SQLMaker::SQLite disables _lock_select
75 require DBIx::Class::SQLMaker;
76 my $sa = DBIx::Class::SQLMaker->new;
78 my ($sql, @bind) = $sa->select('foo', '*', {}, { for => 'update' } );
82 'SELECT * FROM foo FOR UPDATE',
88 my ($sql, @bind) = $sa->select('bar', '*', {}, { for => \'baz' } );
92 'SELECT * FROM bar FOR baz',
101 # Make sure the carp/croak override in SQLA works (via SQLMaker)
102 my $file = quotemeta (__FILE__);
104 $schema->resultset ('Artist')->search ({}, { order_by => { -asc => 'stuff', -desc => 'staff' } } )->as_query;
105 }, qr/$file/, 'Exception correctly croak()ed');