Introduce GOVERNANCE document and empty RESOLUTIONS file.
[dbsrgits/DBIx-Class.git] / t / 18insert_default.t
CommitLineData
c0329273 1BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) }
2
7a72e5a5 3use strict;
4use warnings;
5
6use Test::More;
c0329273 7
7a72e5a5 8use DBICTest;
7a72e5a5 9
10my $schema = DBICTest->init_schema();
20595c02 11$schema->storage->sql_maker->quote_char('"');
12
7a72e5a5 13my $rs = $schema->resultset ('Artist');
14my $last_obj = $rs->search ({}, { order_by => { -desc => 'artistid' }, rows => 1})->single;
15my $last_id = $last_obj ? $last_obj->artistid : 0;
16
17my $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
24ok ($obj, 'Insert defaults ( $rs->create ({}) )' );
7a72e5a5 25
20595c02 26# this should be picked up without calling the DB again
27is ($obj->artistid, $last_id + 1, 'Autoinc PK works');
7a72e5a5 28
20595c02 29# for this we need to refresh
30$obj->discard_changes;
31is ($obj->rank, 13, 'Default value works');
7a72e5a5 32
20595c02 33done_testing;