Skip Menu |

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

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

People
Owner: OLIVER [...] cpan.org
Requestors: stuckdownawell [...] gmail.com
Cc:
AdminCc:

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



Subject: Null FK issue
Hi, Great module, very useful The problem is, that AutoCRUD won't allow an update of a row with a null Foreign Key, even if the field is nullable. The problem is when the fk field is undef, then the the data field for the relationship is not changed to the marked field name. The update then fails because there is not a field in the table with the relationships name. The solution I found, was to change the check on the relation data from defined to exists, so if the field remains null, the field renaming is done. I suppose you could just delete the data as an alternative. Again I really like this module, Thanks Alex
Subject: null_fk.patch
diff -r -u a/lib/Catalyst/Plugin/AutoCRUD/Controller/AJAX.pm b/lib/Catalyst/Plugin/AutoCRUD/Controller/AJAX.pm --- a/lib/Catalyst/Plugin/AutoCRUD/Controller/AJAX.pm 2009-11-29 14:08:43.000000000 +0000 +++ b/lib/Catalyst/Plugin/AutoCRUD/Controller/AJAX.pm 2010-06-25 12:03:50.000000000 +0100 @@ -438,7 +438,7 @@ # rename col to real name, now we have data for it # (custom relation accessor name) $data->{ $ci->{masked_col} } = delete $data->{$col} - if defined $data->{$col} and exists $ci->{masked_col}; + if exists $data->{$col} and exists $ci->{masked_col}; } else { # not a foreign key, so just update the row data
Subject: Re: [rt.cpan.org #58831] Null FK issue
Date: Fri, 25 Jun 2010 12:22:02 +0100
To: bug-Catalyst-Plugin-AutoCRUD [...] rt.cpan.org
From: Oliver Gorwits <oliver.gorwits [...] oucs.ox.ac.uk>
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 25/06/2010 12:16, http://www.google.com/profiles/stuckdownawell via RT wrote: Show quoted text
> The problem is, that AutoCRUD won't allow an update of a row with a null > Foreign Key, even if the field is nullable.
Many thanks for the bug report - I'll look into this next week. regards, oliver. - -- Oliver Gorwits, Network and Telecommunications Group, Oxford University Computing Services -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkwkkVoACgkQ2NPq7pwWBt6YFACePwYhVVpRGEgS8zfY/iFBTuTG Ox4AoIeZdpROXFmomjljuoC9tBkkTqII =PBBW -----END PGP SIGNATURE-----
Hi Alex, Show quoted text
> On 25/06/2010 12:16, http://www.google.com/profiles/stuckdownawell > via RT wrote:
> > The problem is, that AutoCRUD won't allow an update of a row with a null > > Foreign Key, even if the field is nullable.
If I understand your issue correctly, it is fixed in the current developer release of AutoCRUD on CPAN: https://metacpan.org/release/OLIVER/Catalyst-Plugin-AutoCRUD-2.112830_001 In the demo app, I can change clear the entry of a FK in the web form, and then that relation column is set to NULL in the SQL update. regards, oliver.