X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F95sql_maker.t;h=629eed6061d4b6421c4decc16e7374bb904f19b9;hb=b75235fe460933adf4e637e6ef4c0bea5cb57aae;hp=d99d2013f1f61b2321b460b56c1bf8f95a1c411d;hpb=b2b22cd666685403e0c926415efa92e7420e18c4;p=dbsrgits%2FDBIx-Class.git diff --git a/t/95sql_maker.t b/t/95sql_maker.t index d99d201..629eed6 100644 --- a/t/95sql_maker.t +++ b/t/95sql_maker.t @@ -7,11 +7,9 @@ use Test::Exception; use lib qw(t/lib); use DBIC::SqlMakerTest; -plan tests => 4; - use_ok('DBICTest'); -my $schema = DBICTest->init_schema(); +my $schema = DBICTest->init_schema(no_deploy => 1); my $sql_maker = $schema->storage->sql_maker; @@ -49,8 +47,33 @@ my $sql_maker = $schema->storage->sql_maker; ); } +# make sure the cookbook caveat of { $op, \'...' } no longer applies +{ + my ($sql, @bind) = $sql_maker->where({ + last_attempt => \ '< now() - interval "12 hours"', + next_attempt => { '<', \ 'now() - interval "12 hours"' }, + created => [ + { '<=', \ '1969' }, + \ '> 1984', + ], + }); + is_same_sql_bind( + $sql, + \@bind, + 'WHERE + (created <= 1969 OR created > 1984 ) + AND last_attempt < now() - interval "12 hours" + AND next_attempt < now() - interval "12 hours" + ', + [], + ); +} + # Make sure the carp/croak override in SQLA works (via SQLAHacks) my $file = __FILE__; +$file = "\Q$file\E"; throws_ok (sub { $schema->resultset ('Artist')->search ({}, { order_by => { -asc => 'stuff', -desc => 'staff' } } )->as_query; }, qr/$file/, 'Exception correctly croak()ed'); + +done_testing;