Subject: | [PATCH] Validation skipped when using $row->update($fields) |
Calling $row->update({ key => value }) skips validation. Not anymore :)
Subject: | sergio.patch |
diff -rpu orig/Changes DBIx-Class-Validation-0.02004/Changes
--- orig/Changes 2009-06-22 08:52:58.000000000 -0400
+++ DBIx-Class-Validation-0.02004/Changes 2009-07-08 12:37:43.858053189 -0400
@@ -1,5 +1,9 @@
Revision history for DBIx::Class::Validation
+XXX
+ - Fix bug that skipped validation when setting values while doing an
+ update() like this: $row->update($hashref) (Sergio Salvi)
+
0.02004 Mon Jun 22 12:52:00 2009
- Switch dependency to DateTime::Format::SQLite
diff -rpu orig/lib/DBIx/Class/Validation.pm DBIx-Class-Validation-0.02004/lib/DBIx/Class/Validation.pm
--- orig/lib/DBIx/Class/Validation.pm 2009-06-22 08:52:58.000000000 -0400
+++ DBIx-Class-Validation-0.02004/lib/DBIx/Class/Validation.pm 2009-07-08 12:38:49.908390272 -0400
@@ -208,6 +208,9 @@ sub insert {
sub update {
my $self = shift;
+ my $columns = shift;
+
+ $self->set_inflated_columns($columns) if $columns;
$self->validate if $self->validation_auto;
$self->next::method(@_);
};
@@ -225,12 +228,16 @@ L<"DBIx::Class">, L<"FormValidator::Simp
Aran C. Deltac <bluefeet@cpan.org>
-=head1 CONTRIBUTERS
+=head1 CONTRIBUTORS
Tom Kirkpatrick <tkp@cpan.org>
+
Christopher Laco <claco@cpan.org>
+
John Napiorkowski <jjn1056@yahoo.com>
+Sergio Salvi <sergio@developerl.com>
+
=head1 LICENSE
You may distribute this code under the same terms as Perl itself.
Only in DBIx-Class-Validation-0.02004: Makefile
Only in DBIx-Class-Validation-0.02004: Makefile.old
diff -rpu orig/README DBIx-Class-Validation-0.02004/README
--- orig/README 2009-06-22 09:02:08.000000000 -0400
+++ DBIx-Class-Validation-0.02004/README 2009-07-08 12:38:57.688387781 -0400
@@ -117,9 +117,14 @@ SEE ALSO
AUTHOR
Aran C. Deltac <bluefeet@cpan.org>
-CONTRIBUTERS
- Tom Kirkpatrick <tkp@cpan.org> Christopher Laco <claco@cpan.org> John
- Napiorkowski <jjn1056@yahoo.com>
+CONTRIBUTORS
+ Tom Kirkpatrick <tkp@cpan.org>
+
+ Christopher Laco <claco@cpan.org>
+
+ John Napiorkowski <jjn1056@yahoo.com>
+
+ Sergio Salvi <sergio@developerl.com>
LICENSE
You may distribute this code under the same terms as Perl itself.
diff -rpu orig/t/fvs.t DBIx-Class-Validation-0.02004/t/fvs.t
--- orig/t/fvs.t 2009-06-02 13:41:08.000000000 -0400
+++ DBIx-Class-Validation-0.02004/t/fvs.t 2009-07-08 12:32:29.052872161 -0400
@@ -5,7 +5,7 @@ use warnings;
BEGIN {
use lib 't/lib';
- use DBIC::Test tests => 16;
+ use DBIC::Test tests => 17;
}
my $schema = DBIC::Test->init_schema;
@@ -32,6 +32,9 @@ $row->name('food');
$row->update;
is $row->name, 'food', 'valid data accepted';
+eval { $row->update({ name => "a" }) };
+isa_ok $@, 'FormValidator::Simple::Results', '$row->update($fields) also goes through validation';
+
# without auto on update
$row->validation_auto(0);
$row->name('yo');
@@ -79,4 +82,4 @@ if ($@ && $@ =~ /does not support the ch
pass;
} else {
fail('throw exceptionb when module does not support check');
-};
\ No newline at end of file
+};
Only in orig/t: var