Skip to content
Browse files

To fix postgresql 7.4 default values.

Starting with v. 7.4 postgres is returning default-values with datatype in form:
'default value'::data type
This cannot be inserted back to database so DEFAULT keyword must be used.
  • Loading branch information...
1 parent 9723c2d commit ce24824ebacbb95709260400e751efe24d1c4042 paca70 committed Dec 2, 2003
Showing with 3 additions and 3 deletions.
  1. +3 −3 lib/datalib.php
View
6 lib/datalib.php
@@ -765,13 +765,13 @@ function insert_record($table, $dataobject, $returnid=true) {
if ($column->name <> "id") {
if (isset($data[$column->name])) {
if ((string)$data[$column->name] == "" and !empty($column->has_default) and !empty($column->default_value)) {
- $ddd[$column->name] = $column->default_value;
+ $ddd[$column->name] = 'DEFAULT';
} else {
$ddd[$column->name] = $data[$column->name];
}
} else {
if (!empty($column->has_default) and !empty($column->default_value)) {
- $ddd[$column->name] = $column->default_value;
+ $ddd[$column->name] = 'DEFAULT';
}
}
}
@@ -796,7 +796,7 @@ function insert_record($table, $dataobject, $returnid=true) {
$select .= " AND ";
}
$inscolumns .= "$key";
- $insvalues .= "'$value'";
+ $insvalues .= ($value != 'DEFAULT') ? "'$value'" : $value ;
$select .= "$key = '$value'";
}
}

0 comments on commit ce24824

Please sign in to comment.
Something went wrong with that request. Please try again.