mirror of
https://github.com/silverstripe/silverstripe-mssql
synced 2024-10-22 08:05:53 +02:00
BUGFIX: Added default value to decimal field type.
ENHANCEMENT: Added MSSQL::allowPrimaryKeyEditing() method to access SET IDENTITY_INSERT method. BUGFIX: Fix sort by RAND()
This commit is contained in:
parent
293b156cb7
commit
dc080b0e28
@ -705,7 +705,7 @@ class MSSQLDatabase extends Database {
|
||||
|
||||
if($asDbValue)
|
||||
return Array('data_type'=>'decimal', 'numeric_precision'=>'9,2');
|
||||
else return 'decimal(' . $precision . ') not null';
|
||||
else return 'decimal(' . $precision . ') not null default 0';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -893,6 +893,8 @@ class MSSQLDatabase extends Database {
|
||||
public function sqlQueryToString(SQLQuery $sqlQuery) {
|
||||
if (!$sqlQuery->from) return '';
|
||||
|
||||
if($sqlQuery->orderby && strtoupper(trim($sqlQuery->orderby)) == 'RAND()') $sqlQuery->orderby = "NEWID()";
|
||||
|
||||
//TODO: remove me when the limit function supposedly works
|
||||
$sqlQuery->limit='';
|
||||
|
||||
@ -1026,6 +1028,16 @@ class MSSQLDatabase extends Database {
|
||||
return $searchResults;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow auto-increment primary key editing on the given table.
|
||||
* Some databases need to enable this specially.
|
||||
* @param $table The name of the table to have PK editing allowed on
|
||||
* @param $allow True to start, false to finish
|
||||
*/
|
||||
function allowPrimaryKeyEditing($table, $allow = true) {
|
||||
$this->query("SET IDENTITY_INSERT \"$table\" " . ($allow ? "ON" : "OFF"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user