mirror of
https://github.com/silverstripe/silverstripe-mssql
synced 2024-10-22 08:05:53 +02:00
BUGFIX MSSQL stores temporary tables in the "tempdb" database, so special requirements are needed to make this work correctly with SapphireTest assumptions that this table exists in the same database as the project
This commit is contained in:
parent
6bfa6e9d0f
commit
6ae790f3a3
@ -335,7 +335,15 @@ class MSSQLDatabase extends SS_Database {
|
||||
if($fields) foreach($fields as $k => $v) $fieldSchemas .= "\"$k\" $v,\n";
|
||||
|
||||
// Temporary tables start with "#" in MSSQL-land
|
||||
if(!empty($options['temporary'])) $tableName = "#$tableName";
|
||||
if(!empty($options['temporary'])) {
|
||||
$tableName = "#$tableName";
|
||||
// mssql stores temporary tables in the "tempdb" database - we need to drop it first before re-creating it!
|
||||
// We have to do a specific query to do this because it's a special type of table object
|
||||
$drop = DB::query("SELECT 1 FROM tempdb..sysobjects WHERE name LIKE '$tableName%'");
|
||||
if($drop->value()) {
|
||||
DB::query("DROP TABLE $tableName");
|
||||
}
|
||||
}
|
||||
|
||||
$this->query("CREATE TABLE \"$tableName\" (
|
||||
$fieldSchemas
|
||||
|
Loading…
Reference in New Issue
Block a user