Subject: | Appears to fail when inserting new value into table with autoinc PK |
When using LFB on a table which has an autoincrement PK, when adding a
row, the id field appears to be specifically set as NULL which upsets
the database (in this case Postgres).
Table def is (DBIC):-
__PACKAGE__->load_components('Core');
__PACKAGE__->table('command');
__PACKAGE__->add_columns(
'id' => {
data_type => 'integer',
is_auto_increment => 1,
default_value => undef,
is_nullable => 0,
size => 10,
label => 'Command ID',
},
'name' => {
data_type => 'varchar',
is_auto_increment => 0,
default_value => undef,
is_nullable => 0,
size => 64,
label => 'Command Name',
},
'description' => {
data_type => 'varchar',
is_auto_increment => 0,
default_value => undef,
is_nullable => 0,
size => 64,
label => 'Command Description',
},
'requires_vm' => {
data_type => 'boolean',
is_auto_increment => 0,
default_value => undef,
is_nullable => 0,
size => 2,
label => 'Requires VM',
comment => 'If true then this command requires a VM reference.',
},
'requires_state' => {
data_type => 'boolean',
is_auto_increment => 0,
default_value => undef,
is_nullable => 0,
size => 2,
label => 'Requires State',
comment =>
'If true then this command requires a VM to be in a particular power
state.',
},
'requires_poweron' => {
data_type => 'boolean',
is_auto_increment => 0,
default_value => undef,
is_nullable => 0,
size => 2,
label => 'Requires State',
comment =>
'If requires_state then true means VM must be running, false means VM
must be off.',
},
);
__PACKAGE__->set_primary_key('id');
Error seen (after instrumenting the txn_do in AJAX.pm to report errors):-
[debug] TXN failed - DBI Exception: DBD::Pg::st execute failed: ERROR:
null value in column "id" violates not-null constraint [for Statement
"INSERT INTO command (description, id, name, requires_poweron,
requires_state, requires_vm) VALUES (?, ?, ?, ?, ?, ?)" with
ParamValues: 6='true', 4='false', 1='Change the name of a VM',
3='VM_RENAME', 2=undef, 5='false'] at
/Library/Perl/5.8.8/DBIx/Class/Schema.pm line 998