From b8b85a12a2e65eb0f36608481ab2eed003f99ea7 Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Wed, 3 Feb 2010 07:27:50 +0000 Subject: [PATCH] ENHANCEMENT MSSQLDatabase::decimal() field type now accepts user defined default values if it's available --- code/MSSQLDatabase.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/code/MSSQLDatabase.php b/code/MSSQLDatabase.php index 64b46f5..3b6b9ee 100644 --- a/code/MSSQLDatabase.php +++ b/code/MSSQLDatabase.php @@ -872,9 +872,16 @@ class MSSQLDatabase extends SS_Database { $precision = $values['precision']; } - if($asDbValue) - return Array('data_type'=>'decimal', 'numeric_precision'=>'9,2'); - else return 'decimal(' . $precision . ') not null default 0'; + $defaultValue = '0'; + if(isset($values['default']) && is_numeric($values['default'])) { + $defaultValue = $values['default']; + } + + if($asDbValue) { + return array('data_type'=>'decimal', 'numeric_precision'=>'9,2'); + } else { + return 'decimal(' . $precision . ') not null default ' . $defaultValue; + } } /**