Skip Menu |

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

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

People
Owner: OLIVER [...] cpan.org
Requestors: jleu [...] mindspring.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Consecutive 'Add New' updates previous data
Date: Fri, 26 Dec 2008 10:45:29 -0600
To: bug-CatalystX-ListFramework-Builder [...] rt.cpan.org
From: "James R. Leu" <jleu [...] mindspring.com>
I'm not sure the best way to report this. First I'll describe the issue then provide my config, and then snippets of output from the cat app. I've tried to dig into the code, but everything leads me back to the sneaking suspicion that I have something setup wrong. Description =========== After restarting the catalyst app, I can click the 'Add new' button and successfully add a new row of data (row_new). Every subsequent attempt to use the 'Add new' button will result 'row_new' getting updated instead of a new row being inserted. This continues until I restart the catalyst app. Attempt to refresh the app (web browser reload) does not change the behavior. Config ====== demo.conf --------- extjs2 /static/ext-2.2 <Model::LFB::DBIC> schema_class FOO connect_info dbi:mysql:dbname=FOO;host=localhost;port=3321; connect_info username connect_info password <connect_info> AutoCommit 1 </connect_info> </Model::LFB::DBIC> FOO.pm ------ package FOO; use base qw/DBIx::Class::Schema/; __PACKAGE__->load_classes({ FOO => [qw/ OutageData /], }); 1; FOO/OutageData.pm ----------------- package ATC::OutageData; use base qw/DBIx::Class/; __PACKAGE__->load_components(qw/PK::Auto Core/); __PACKAGE__->table('OutageData'); __PACKAGE__->add_columns( id => { is_auto_increment => 1, data_type => 'integer', is_nullable => 0, default_value => '', }, Device_ID, Ticket_Number, Carrier_Name, Site_ID, Bands_Affected, Duration_of_Outage, Number_of_Antenna, ); __PACKAGE__->set_primary_key('id'); 1; mysql schema ------------ CREATE TABLE `OutageData` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `Device_ID` varchar(64) NOT NULL, `Ticket_Number` varchar(64) NOT NULL, `Carrier_Name` varchar(64) NOT NULL, `Site_ID` varchar(64) NOT NULL, `Bands_Affected` varchar(64) NOT NULL, `Duration_of_Outage` float NOT NULL, `Number_of_Antenna` float NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM Catalyst App debug ================== I uncommented the debug statements in 'AJAX::update' First 'add new' after cat app started ------------------------------------- $VAR1 = [ { 'Device_ID' => '1111', 'Bands_Affected' => 'None', 'Ticket_Number' => '2222', 'Carrier_Name' => 'Leu', 'Number_of_Antenna' => '4', 'Site_ID' => '3333', 'Duration_of_Outage' => '4' }, 'LFB::DBIC::OutageData' ]; BEGIN WORK SELECT me.id, me.Device_ID, me.Ticket_Number, me.Carrier_Name, me.Site_ID, me.Bands_Affected, me.Duration_of_Outage, me.Number_of_Antenna FROM OutageData me WHERE ( ( me.id IS NULL ) ): INSERT INTO OutageData (Bands_Affected, Carrier_Name, Device_ID, Duration_of_Outage, Number_of_Antenna, Site_ID, Ticket_Number) VALUES (?, ?, ?, ?, ?, ?, ?): 'None', 'Leu', '1111', '4', '4', '3333', '2222' COMMIT [info] *** Request 5 (0.143/s) [19962] [Fri Dec 26 10:19:56 2008] *** [debug] Body Parameters are: .-------------------------------------+--------------------------------------. | Parameter | Value | +-------------------------------------+--------------------------------------+ | Bands_Affected | None | | Carrier_Name | Leu | | Device_ID | 1111 | | Duration_of_Outage | 4 | | Number_of_Antenna | 4 | | Site_ID | 3333 | | Ticket_Number | 2222 | | id | | '-------------------------------------+--------------------------------------' Next add new ------------ $VAR1 = [ { 'Device_ID' => '4444', 'Bands_Affected' => 'None', 'Ticket_Number' => '55555', 'Carrier_Name' => 'Leu', 'Number_of_Antenna' => '5', 'Site_ID' => '66666', 'Duration_of_Outage' => '5' }, 'LFB::DBIC::OutageData' ]; BEGIN WORK SELECT me.id, me.Device_ID, me.Ticket_Number, me.Carrier_Name, me.Site_ID, me.Bands_Affected, me.Duration_of_Outage, me.Number_of_Antenna FROM OutageData me WHERE ( ( me.id IS NULL ) ): UPDATE OutageData SET Device_ID = ?, Duration_of_Outage = ?, Number_of_Antenna = ?, Site_ID = ?, Ticket_Number = ? WHERE ( id = ? ): '4444', '5', '5', '66666', '55555', '24' COMMIT [info] *** Request 7 (0.125/s) [19962] [Fri Dec 26 10:20:17 2008] *** [debug] Body Parameters are: .-------------------------------------+--------------------------------------. | Parameter | Value | +-------------------------------------+--------------------------------------+ | Bands_Affected | None | | Carrier_Name | Leu | | Device_ID | 4444 | | Duration_of_Outage | 5 | | Number_of_Antenna | 5 | | Site_ID | 66666 | | Ticket_Number | 55555 | | id | | '-------------------------------------+--------------------------------------' -- James R. Leu jleu@mindspring.com
Download (untitled)
application/pgp-signature 189b

Message body not shown because it is not plain text.

From: jleu [...] mindspring.com
I found the attached patch works around the issue.
--- lib/CatalystX/ListFramework/Builder/Controller/AJAX.pm 2008-12-26 09:53:11.000000000 -0600 +++ /usr/lib/perl5/site_perl/5.8.8/CatalystX/ListFramework/Builder/Controller/AJAX.pm 2008-12-26 12:26:28.000000000 -0600 @@ -338,7 +338,10 @@ # update or create the row; could this use a magic DBIC method? my $pk = $lf->{table_info}->{$model}->{pk}; - my $row = eval { $c->model($model)->find( $data->{ $pk } ) }; + my $row = undef; + if (defined($data->{ $pk })) { + $row = eval { $c->model($model)->find( $data->{ $pk } ) }; + } $row = ( (blessed $row) ? $row->set_columns( $data ) : $c->model($model)->new_result( $data ) );
Hi James, On Fri Dec 26 11:45:50 2008, jleu@mindspring.com wrote: Show quoted text
> After restarting the catalyst app, I can click the 'Add new' button > and > successfully add a new row of data (row_new). Every subsequent > attempt to > use the 'Add new' button will result 'row_new' getting updated instead > of a new row being inserted.
Many thanks indeed for this bug report! I have uploaded a new version, CatalystX::ListFramework::Builder 0.37, to CPAN just now, with your fix applied (slightly edited). I'd be grateful if you could let me know whether this resolves the issue. Many thanks again for taking the time to report it. regards, oliver.
Hello, I just got around to verifying that 0.38 does fix my issue. Thank you!