sub replace {
my ( $new, $old ) = ( shift, shift );
+ warn "[debug][FS::Record] $new ->replace $old\n" if $DEBUG;
my @diff = grep $new->getfield($_) ne $old->getfield($_), $old->fields;
unless ( @diff ) {
- carp "warning: records identical";
+ carp "[warning][FS::Record] $new -> replace $old: records identical";
return '';
}
=cut
sub ut_anything {
- my($self,$field)=@_;
+ my( $self, $field ) = @_;
$self->getfield($field) =~ /^(.*)$/s
or return "Illegal $field: ". $self->getfield($field);
$self->setfield($field,$1);
'';
}
+=item ut_enum COLUMN CHOICES_ARRAYREF
+
+Check/untaint a column, supplying all possible choices, like the "enum" type.
+
+=cut
+
+sub ut_enum {
+ my( $self, $field, $choices ) = @_;
+ foreach my $choice ( @$choices ) {
+ if ( $self->getfield($field) eq $choice ) {
+ $self->setfield($choice);
+ return '';
+ }
+ }
+ return "Illegal (enum) field $field: ". $self->getfield($field);
+}
+
=item fields [ TABLE ]
This can be used as both a subroutine and a method call. It returns a list
}
#croak "Usage: \@fields = fields(\$table)\n or: \@fields = \$record->fields" unless $table;
my($table_obj) = $dbdef->table($table);
- croak "Unknown table $table" unless $table_obj;
+ confess "Unknown table $table" unless $table_obj;
$table_obj->columns;
}
=head1 VERSION
-$Id: Record.pm,v 1.26 2001-08-31 09:20:35 ivan Exp $
+$Id: Record.pm,v 1.29 2001-09-16 12:45:35 ivan Exp $
=head1 BUGS