FIX Silverstripe expects dates as strings

This commit is contained in:
Will Rossiter 2020-10-13 16:08:27 +13:00
parent cc80227614
commit 0cc9a140cd
No known key found for this signature in database
GPG Key ID: F24330E3B4B95B75
3 changed files with 12 additions and 7 deletions

View File

@ -57,6 +57,7 @@ class MSSQLAzureDatabase extends MSSQLDatabase
{
$parameters = $this->parameters;
$parameters['database'] = $database;
$parameters['returndatesasstrings'] = 1;
$parameters['multipleactiveresultsets'] = 1;
// Ensure that driver is available (required by PDO)

View File

@ -45,7 +45,8 @@ class MSSQLDatabaseConfigurationHelper implements DatabaseConfigurationHelper
// Azure has additional parameter requirements
if ($this->isAzure($databaseConfig)) {
$parameters['database'] = $databaseConfig['database'];
$parameters['multipleactiveresultsets'] = 0;
$parameters['multipleactiveresultsets'] = 1;
$parameters['returndatesasstrings'] = 1;
}
$conn = @sqlsrv_connect($databaseConfig['server'], $parameters);

View File

@ -47,13 +47,16 @@ class SQLServerConnector extends DBConnector
}
$charset = isset($parameters['charset']) ? $parameters : 'UTF-8';
$multiResultSets = isset($parameters['multipleactiveresultsets'])
? $parameters['multipleactiveresultsets']
: true;
$options = array(
$options = [
'CharacterSet' => $charset,
'MultipleActiveResultSets' => $multiResultSets
);
'ReturnDatesAsStrings' => isset($parameters['returndatesasstrings'])
? $parameters['returndatesasstrings']
: true,
'MultipleActiveResultSets' => isset($parameters['multipleactiveresultsets'])
? $parameters['multipleactiveresultsets']
: true
];
if (!(defined('MSSQL_USE_WINDOWS_AUTHENTICATION') && MSSQL_USE_WINDOWS_AUTHENTICATION == true)
&& empty($parameters['windowsauthentication'])