From c97973a5145438eedd9fe16841897f5c4febb995 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 8 May 2003 09:34:39 +0000 Subject: [PATCH] general Pg 7.3 fix for setting int columns to '' / NULL --- FS/FS/Record.pm | 22 +++++++++++++++------- Makefile | 2 +- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm index c711f1214..9a724feac 100644 --- a/FS/FS/Record.pm +++ b/FS/FS/Record.pm @@ -1231,15 +1231,23 @@ type (see L) 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); } } diff --git a/Makefile b/Makefile index 92f82067b..433563e36 100644 --- a/Makefile +++ b/Makefile @@ -50,7 +50,7 @@ SIGNUP_MACHINE = localhost SIGNUP_AGENTNUM = 2 SIGNUP_REFNUM = 2 -SELFSERVICE_USER = nostart +SELFSERVICE_USER = fs_selfservice SELFSERVICE_MACHINE = localhost #--- -- 2.11.0