From 2dea7078530a565f2300b52b6d235b5eaf2df9e0 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 8 May 2003 09:34:43 +0000 Subject: [PATCH] general Pg 7.3 fix for setting int columns to '' / NULL --- FS/FS/Record.pm | 22 +++++++++++++++------- Makefile | 4 ++-- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm index d783870cc..5cf77d3e7 100644 --- a/FS/FS/Record.pm +++ b/FS/FS/Record.pm @@ -1167,15 +1167,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 dfd3c0607..c48f5e91a 100644 --- a/Makefile +++ b/Makefile @@ -45,8 +45,8 @@ SELFSERVICE_MACHINE = localhost #not changable yet FREESIDE_CONF = /usr/local/etc/freeside -VERSION=1.4.1rc1 -TAG=freeside_1_4_1rc1 +VERSION=1.4.1rc2 +TAG=freeside_1_4_1rc2 help: @echo "supported targets: aspdocs masondocs alldocs docs install-docs" -- 2.11.0