Skip Menu |

This queue is for tickets about the CatalystX-ListFramework-Builder CPAN distribution.

Report information
The Basics
Id: 38990
Status: resolved
Priority: 0/
Queue: CatalystX-ListFramework-Builder

People
Owner: OLIVER [...] cpan.org
Requestors: nigel.metheringham [...] Dev.intechnology.co.uk
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.33
Fixed in: 0.34



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
On Thu Sep 04 11:23:12 2008, nigel.metheringham@Dev.intechnology.co.uk wrote: Show quoted text
> 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', > },
Nice gotcha in the code, here... normally the is_auto_increment is respected and so the field is not editable in the UI, so it gets no value, so it's not parsed. But with the default_value set (even to undef) that was being ignored, so I've tightened it up. Not sure whether default_value => undef comes in from yourself, or DBIC::Schema::Loader, but it doesn't make sense to have that on a field with is_nullable => 0 to me, at least. This is not relevant to the bug of course! Thanks for the report. I'll resolve this ticket when I've cut the new release and I know it's working for you. regards, oliver.