summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorivan <ivan>2004-01-31 06:20:40 +0000
committerivan <ivan>2004-01-31 06:20:40 +0000
commit944a9c65010c5fea6dbcb7a937368c30edfec2a0 (patch)
tree37aff1401f45254709babcd33ef5a758d408219f
parent2b0fc43037f2dda61ba0f0c139ffe25d74d18c3a (diff)
add ut_snumber, fix replacement of records with empty values in non-primary-keyed tables
-rw-r--r--FS/FS/Record.pm17
1 files changed, 16 insertions, 1 deletions
diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm
index 331de0225..98acaf522 100644
--- a/FS/FS/Record.pm
+++ b/FS/FS/Record.pm
@@ -651,7 +651,7 @@ sub replace {
$old->getfield($_) eq ''
#? "( $_ IS NULL OR $_ = \"\" )"
? ( driver_name =~ /^Pg$/i
- ? "$_ IS NULL"
+ ? "( $_ IS NULL OR $_ = '' ) "
: "( $_ IS NULL OR $_ = \"\" )"
)
: "$_ = ". _quote($old->getfield($_),$old->table,$_)
@@ -792,6 +792,21 @@ sub ut_float {
'';
}
+=item ut_snumber COLUMN
+
+Check/untaint signed numeric data (whole numbers). May not be null. If there
+is an error, returns the error, otherwise returns false.
+
+=cut
+
+sub ut_snumber {
+ my($self, $field) = @_;
+ $self->getfield($field) =~ /^(-?)\s*(\d+)$/
+ or return "Illegal or empty (numeric) $field: ". $self->getfield($field);
+ $self->setfield($field, "$1$2");
+ '';
+}
+
=item ut_number COLUMN
Check/untaint simple numeric data (whole numbers). May not be null. If there