summaryrefslogtreecommitdiff
path: root/FS/FS/Record.pm
diff options
context:
space:
mode:
Diffstat (limited to 'FS/FS/Record.pm')
-rw-r--r--FS/FS/Record.pm22
1 files changed, 15 insertions, 7 deletions
diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm
index d783870..5cf77d3 100644
--- a/FS/FS/Record.pm
+++ b/FS/FS/Record.pm
@@ -1167,15 +1167,23 @@ type (see L<DBIx::DBSchema::Column>) does not end in `char' or `binary'.
=cut
sub _quote {
- my($value,$table,$field)=@_;
- my($dbh)=dbh;
- if ( $value =~ /^\d+(\.\d+)?$/ &&
-# ! ( datatype($table,$field) =~ /^char/ )
- ! $dbdef->table($table)->column($field)->type =~ /(char|binary|text)$/i
- ) {
+ my($value, $table, $column) = @_;
+ my $column_obj = $dbdef->table($table)->column($column);
+ my $column_type = $column_obj->type;
+
+ if ( $value eq '' && $column_type =~ /^int/ ) {
+ if ( $column_obj->null ) {
+ 'NULL';
+ } else {
+ cluck "WARNING: Attempting to set non-null integer $table.$column null; ".
+ "using 0 instead";
+ 0;
+ }
+ } elsif ( $value =~ /^\d+(\.\d+)?$/ &&
+ ! $column_type =~ /(char|binary|text)$/i ) {
$value;
} else {
- $dbh->quote($value);
+ dbh->quote($value);
}
}