9 use DBIC::SqlMakerTest;
11 my $schema = DBICTest->init_schema();
12 $schema->storage->sql_maker->quote_char('"');
14 my $rs = $schema->resultset ('Artist');
15 my $last_obj = $rs->search ({}, { order_by => { -desc => 'artistid' }, rows => 1})->single;
16 my $last_id = $last_obj ? $last_obj->artistid : 0;
20 my $orig_debugobj = $schema->storage->debugobj;
21 my $orig_debug = $schema->storage->debug;
23 $schema->storage->debugobj (DBIC::DebugObj->new (\$sql, \@bind) );
24 $schema->storage->debug (1);
27 lives_ok { $obj = $rs->create ({}) } 'Default insert successful';
29 $schema->storage->debugobj ($orig_debugobj);
30 $schema->storage->debug ($orig_debug);
35 'INSERT INTO "artist" DEFAULT VALUES',
37 'Default-value insert correct SQL',
40 ok ($obj, 'Insert defaults ( $rs->create ({}) )' );
42 # this should be picked up without calling the DB again
43 is ($obj->artistid, $last_id + 1, 'Autoinc PK works');
45 # for this we need to refresh
46 $obj->discard_changes;
47 is ($obj->rank, 13, 'Default value works');