my
$schema
= DBICTest->init_schema();
$schema
->storage->sql_maker->quote_char(
'"'
);
my
$rs
=
$schema
->resultset (
'Artist'
);
my
$last_obj
=
$rs
->search ({}, {
order_by
=> {
-desc
=>
'artistid'
},
rows
=> 1})->single;
my
$last_id
=
$last_obj
?
$last_obj
->artistid : 0;
my
(
$sql
,
@bind
);
my
$orig_debugobj
=
$schema
->storage->debugobj;
my
$orig_debug
=
$schema
->storage->debug;
$schema
->storage->debugobj (DBIC::DebugObj->new (\
$sql
, \
@bind
) );
$schema
->storage->debug (1);
my
$obj
;
lives_ok {
$obj
=
$rs
->create ({}) }
'Default insert successful'
;
$schema
->storage->debugobj (
$orig_debugobj
);
$schema
->storage->debug (
$orig_debug
);
is_same_sql_bind (
$sql
,
\
@bind
,
'INSERT INTO "artist" DEFAULT VALUES'
,
[],
'Default-value insert correct SQL'
,
);
ok (
$obj
,
'Insert defaults ( $rs->create ({}) )'
);
is (
$obj
->artistid,
$last_id
+ 1,
'Autoinc PK works'
);
$obj
->discard_changes;
is (
$obj
->rank, 13,
'Default value works'
);
done_testing;