Skip Menu |

This queue is for tickets about the Catalyst-Plugin-AutoCRUD CPAN distribution.

Report information
The Basics
Id: 64455
Status: resolved
Priority: 0/
Queue: Catalyst-Plugin-AutoCRUD

People
Owner: OLIVER [...] cpan.org
Requestors: maxl.mayr [...] aon.at
paul [...] bonnydeal.com
Cc:
AdminCc:

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



Subject: "Has not been saved" error for certain database structure.
The following three tables are given (MySQL, should not matter for the issue). You may think of the reference table containing some books, which are cited in the tables a and b: CREATE TABLE reference ( id INTEGER PRIMARY KEY AUTO_INCREMENT ); CREATE TABLE a ( id INTEGER PRIMARY KEY AUTO_INCREMENT, reference INTEGER REFERENCES reference(id) ); CREATE TABLE b ( id INTEGER PRIMARY KEY AUTO_INCREMENT, a INTEGER REFERENCES a(id), reference INTEGER REFERENCES reference(id) ); Furthermore, for the DBIx::Class scheme of "a" we have a belongs_to relation reference => 'Scheme::Result::Reference' and for the scheme of "b" we have reference => 'Scheme::Result::Reference' as well as a => 'Scheme::Result::Reference'. In this situation an error occurs when trying to enter information into the table "b". My guess is, that the AJAX template does not use form names that are concise enough in this situation. Two combo boxes with the same name "reference" are created, one in the main form and one in the tab "Create new a". As a result the Controller seems to think that "reference" takes an array of values. Changing the belongs_to relation in 'Scheme::Result::B' to 'reference_' => 'Scheme::Result::Reference', 'reference' seems to fix the issue as a workaround. For the sake of completeness: My perl version is 5.10.1. I am using Debian Squeeze, installed Catalyst, all modules and extra-modules via APT and Catalyst::Plugin::AutoCRUD via CPAN. uname -svrmo returns Linux 2.6.32-5-amd64 #1 SMP Fri Dec 10 15:35:08 UTC 2010 x86_64 GNU/Linux I am using the current stable version, i.e. 0.68 of Catalyst::Plugin::AutoCRUD.
Hi Maxl, Many thanks for your bug report. On Tue Jan 04 07:50:10 2011, desertmax wrote: Show quoted text
> My guess is, that the AJAX template does not use form names that are > concise > enough in this situation. Two combo boxes with the same name > "reference" are > created, one in the main form and one in the tab "Create new a". As a > result the > Controller seems to think that "reference" takes an array of values.
Yes this could be the case - there is a note in the documentation about a similar situation: "No two columns in a given table may have the same FK constraint" however in your case the FK constrains are in two tables. But I think the issue is the same - the naming of the combobox fields. I will do some tests. Either there will be a straightforward patch, which I hope, or this might need to wait for me to re-engineer some of the AJAX processing. Thanks once again for the bug report. regards, oliver.
Subject: Bug #64455 for Catalyst-Plugin-AutoCRUD: "Has not been saved" error for certain database structure.
Date: Fri, 11 Feb 2011 14:01:21 -0000
To: bug-Catalyst-Plugin-AutoCRUD [...] rt.cpan.org
From: Paul Young <paul [...] bonnydeal.com>
Hi, I have encountered this bug and can report that I am able to save rows when using the lazy loading technique. i.e not specifying schema_class in the config file <Model::AutoCRUD::DBIC></Model::AutoCRUD::DBIC> section. Kind Regards, Paul Young
Hello Maxl and Paul, First, many thanks indeed for reporting this bug to me, and for providing details to help me debug. I'm pleased to say that a new version of AutoCRUD will be released to CPAN with a fix. This version will be a development release ("_002") but is considered stable enough to use. So if you are still using the module, please keep an eye out for updates in the next couple of days, and a non-development release shortly after. regards, oliver.
CC: oliver [...] cpan.org
Subject: RE: [rt.cpan.org #64455] "Has not been saved" error for certain database structure.
Date: Sat, 15 Oct 2011 20:38:30 +0100
To: bug-Catalyst-Plugin-AutoCRUD [...] rt.cpan.org
From: Paul Young <paul [...] bonnydeal.com>
Hi Oliver, I am indeed still using this excellent module. My thanks go to you for providing it. I have come up with a messy way of controlling the display of foreign keys from the config file - basically putting another method into the appropriate schema package for each display_name defined in the config. Obviously only works for simple functions, and I don't know if this works after version 1.11. You are welcome to use, improve or discard. In the application config: <Model::AutoCRUD::DBIC> <display_name> default $self->name || $self->description || '' Invoice $self->reference || '---' Person $self->firstname . ' ' . $self->lastname || 'unknown' </display_name> </Model::AutoCRUD::DBIC> Then in lib/<Application>.pm After __PACKAGE__->setup(); # # Adjust display_name as required by <display_name></display_name> settings: my $hash = __PACKAGE__->config->{'Model::AutoCRUD::DBIC'}; #my $schema_class = $hash->{schema_class}; my $schema_class = 'IntelliAdmin::Model::AutoCRUD::DBIC'; foreach my $table ( keys %{$hash->{display_name}} ) { my $package = $table =~ /default/ ? 'DBIx::Class::Core' : $schema_class . '::' . $table; my $method = sprintf '*{%s::display_name} = sub{ my $self = shift; %s }', $package, $hash->{display_name}->{$table}; eval $method; } Thanks again for an excellent module, and for taking the time to maintain it. Kind Regards, Paul Show quoted text
-----Original Message----- From: Oliver Gorwits via RT [mailto:bug-Catalyst-Plugin-AutoCRUD@rt.cpan.org] Sent: 15 October 2011 16:06 To: maxl.mayr@aon.at; paul@bonnydeal.com Subject: [rt.cpan.org #64455] "Has not been saved" error for certain database structure. <URL: https://rt.cpan.org/Ticket/Display.html?id=64455 > Hello Maxl and Paul, First, many thanks indeed for reporting this bug to me, and for providing details to help me debug. I'm pleased to say that a new version of AutoCRUD will be released to CPAN with a fix. This version will be a development release ("_002") but is considered stable enough to use. So if you are still using the module, please keep an eye out for updates in the next couple of days, and a non-development release shortly after. regards, oliver. No virus found in this incoming message. Checked by AVG - www.avg.com Version: 9.0.917 / Virus Database: 271.1.1/3943 - Release Date: 10/12/11 07:39:00