Commit | Line | Data |
c0329273 |
1 | BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) } |
2 | |
7a72e5a5 |
3 | use strict; |
4 | use warnings; |
5 | |
6 | use Test::More; |
c0329273 |
7 | |
7a72e5a5 |
8 | use DBICTest; |
7a72e5a5 |
9 | |
10 | my $schema = DBICTest->init_schema(); |
20595c02 |
11 | $schema->storage->sql_maker->quote_char('"'); |
12 | |
7a72e5a5 |
13 | my $rs = $schema->resultset ('Artist'); |
14 | my $last_obj = $rs->search ({}, { order_by => { -desc => 'artistid' }, rows => 1})->single; |
15 | my $last_id = $last_obj ? $last_obj->artistid : 0; |
16 | |
17 | my $obj; |
2cfc22dd |
18 | $schema->is_executed_sql_bind( sub { |
19 | $obj = $rs->create ({}) |
20 | }, [[ |
21 | 'INSERT INTO "artist" DEFAULT VALUES' |
22 | ]], 'Default-value insert correct SQL' ); |
7a72e5a5 |
23 | |
24 | ok ($obj, 'Insert defaults ( $rs->create ({}) )' ); |
7a72e5a5 |
25 | |
20595c02 |
26 | # this should be picked up without calling the DB again |
27 | is ($obj->artistid, $last_id + 1, 'Autoinc PK works'); |
7a72e5a5 |
28 | |
20595c02 |
29 | # for this we need to refresh |
30 | $obj->discard_changes; |
31 | is ($obj->rank, 13, 'Default value works'); |
7a72e5a5 |
32 | |
20595c02 |
33 | done_testing; |