Commit | Line | Data |
c0329273 |
1 | BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) } |
2 | |
d5130dd2 |
3 | use strict; |
68de9438 |
4 | use warnings; |
d5130dd2 |
5 | |
6 | use Test::More; |
c0329273 |
7 | |
d5130dd2 |
8 | use DBICTest; |
d5130dd2 |
9 | |
6e6ad6c3 |
10 | { # Fake storage driver for SQLite + no bind variables |
11 | package DBICTest::SQLite::NoBindVars; |
2cfc22dd |
12 | use base qw( |
13 | DBIx::Class::Storage::DBI::NoBindVars |
14 | DBIx::Class::Storage::DBI::SQLite |
15 | ); |
16 | use mro 'c3'; |
d5130dd2 |
17 | } |
18 | |
6e6ad6c3 |
19 | my $schema = DBICTest->init_schema (storage_type => 'DBICTest::SQLite::NoBindVars', no_populate => 1); |
d5130dd2 |
20 | |
21 | # test primary key handling |
3ff5b740 |
22 | my $new = $schema->resultset('Artist')->create({ name => 'foo' }); |
d5130dd2 |
23 | ok($new->artistid, "Auto-PK worked"); |
24 | |
25 | # test LIMIT support |
26 | for (1..6) { |
3ff5b740 |
27 | $schema->resultset('Artist')->create({ name => 'Artist ' . $_ }); |
d5130dd2 |
28 | } |
3ff5b740 |
29 | my $it = $schema->resultset('Artist')->search( {}, |
d5130dd2 |
30 | { rows => 3, |
31 | offset => 2, |
32 | order_by => 'artistid' } |
33 | ); |
6e6ad6c3 |
34 | |
fb4b58e8 |
35 | is( $it->count, 3, "LIMIT count ok" ); # ask for 3 rows out of 7 artists |
6e6ad6c3 |
36 | |
2cfc22dd |
37 | $schema->is_executed_sql_bind( sub { |
38 | is( $it->next->name, "Artist 2", "iterator->next ok" ); |
39 | $it->next; |
40 | $it->next; |
41 | is( $it->next, undef, "next past end of resultset ok" ); |
42 | }, [ |
43 | [ 'SELECT me.artistid, me.name, me.rank, me.charfield FROM artist me ORDER BY artistid LIMIT 3 OFFSET 2' ], |
44 | ], 'Correctly interpolated SQL' ); |
68de9438 |
45 | |
46 | done_testing; |