From 7e9529cd00deddd8522c6fcdc8716ef834f336fd Mon Sep 17 00:00:00 2001 From: Romain Quetiez Date: Fri, 25 Jun 2010 15:34:12 +0000 Subject: [PATCH] Default value for Integer attributes is now casted to int SVN:trunk[485] --- core/attributedef.class.inc.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/attributedef.class.inc.php b/core/attributedef.class.inc.php index 23258de14..fece3cdce 100644 --- a/core/attributedef.class.inc.php +++ b/core/attributedef.class.inc.php @@ -363,7 +363,7 @@ class AttributeDBFieldVoid extends AttributeDefinition public function IsScalar() {return true;} public function IsWritable() {return true;} public function GetSQLExpr() {return $this->Get("sql");} - public function GetDefaultValue() {return "";} + public function GetDefaultValue() {return $this->MakeRealValue("");} public function IsNullAllowed() {return false;} // @@ -436,7 +436,7 @@ class AttributeDBField extends AttributeDBFieldVoid { return array_merge(parent::ListExpectedParams(), array("default_value", "is_null_allowed")); } - public function GetDefaultValue() {return $this->Get("default_value");} + public function GetDefaultValue() {return $this->MakeRealValue($this->Get("default_value"));} public function IsNullAllowed() {return $this->Get("is_null_allowed");} } @@ -515,11 +515,12 @@ class AttributeInteger extends AttributeDBField public function MakeRealValue($proposedValue) { //return intval($proposedValue); could work as well + if ($proposedValue == '') return null; return (int)$proposedValue; } public function ScalarToSQL($value) { - assert(is_numeric($value)); + assert(is_numeric($value) || is_null($value)); return $value; // supposed to be an int } }