general Pg 7.3 fix for setting int columns to '' / NULL
authorivan <ivan>
Thu, 8 May 2003 09:34:39 +0000 (09:34 +0000)
committerivan <ivan>
Thu, 8 May 2003 09:34:39 +0000 (09:34 +0000)
FS/FS/Record.pm
Makefile

index c711f12..9a724fe 100644 (file)
@@ -1231,15 +1231,23 @@ type (see L<DBIx::DBSchema::Column>) does not end in `char' or `binary'.
 =cut
 
 sub _quote {
 =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 {
     $value;
   } else {
-    $dbh->quote($value);
+    dbh->quote($value);
   }
 }
 
   }
 }
 
index 92f8206..433563e 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -50,7 +50,7 @@ SIGNUP_MACHINE = localhost
 SIGNUP_AGENTNUM = 2
 SIGNUP_REFNUM = 2
 
 SIGNUP_AGENTNUM = 2
 SIGNUP_REFNUM = 2
 
-SELFSERVICE_USER = nostart
+SELFSERVICE_USER = fs_selfservice
 SELFSERVICE_MACHINE = localhost
 
 #---
 SELFSERVICE_MACHINE = localhost
 
 #---