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