Add a self-explanatory *compile-time* $ENV{DBIC_SHUFFLE_UNORDERED_RESULTSETS}
[dbsrgits/DBIx-Class.git] / t / 18insert_default.t
CommitLineData
7a72e5a5 1use strict;
2use warnings;
3
4use Test::More;
5use lib qw(t/lib);
6use DBICTest;
7a72e5a5 7
8my $schema = DBICTest->init_schema();
20595c02 9$schema->storage->sql_maker->quote_char('"');
10
7a72e5a5 11my $rs = $schema->resultset ('Artist');
12my $last_obj = $rs->search ({}, { order_by => { -desc => 'artistid' }, rows => 1})->single;
13my $last_id = $last_obj ? $last_obj->artistid : 0;
14
15my $obj;
2cfc22dd 16$schema->is_executed_sql_bind( sub {
17 $obj = $rs->create ({})
18}, [[
19 'INSERT INTO "artist" DEFAULT VALUES'
20]], 'Default-value insert correct SQL' );
7a72e5a5 21
22ok ($obj, 'Insert defaults ( $rs->create ({}) )' );
7a72e5a5 23
20595c02 24# this should be picked up without calling the DB again
25is ($obj->artistid, $last_id + 1, 'Autoinc PK works');
7a72e5a5 26
20595c02 27# for this we need to refresh
28$obj->discard_changes;
29is ($obj->rank, 13, 'Default value works');
7a72e5a5 30
20595c02 31done_testing;