Skip to content

Commit 3715280

Browse files
committed
set collation for sqlsrv
1 parent e5ebbbb commit 3715280

File tree

6 files changed

+16
-15
lines changed

6 files changed

+16
-15
lines changed

.github/workflows/reusable-phpunit-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ jobs:
138138
steps:
139139
- name: Create database for MSSQL Server
140140
if: ${{ inputs.db-platform == 'SQLSRV' }}
141-
run: sqlcmd -S 127.0.0.1 -U sa -P 1Secure*Password1 -Q "CREATE DATABASE test"
141+
run: sqlcmd -S 127.0.0.1 -U sa -P 1Secure*Password1 -Q "CREATE DATABASE test COLLATE Latin1_General_100_CS_AS_SC_UTF8"
142142

143143
- name: Install latest ImageMagick
144144
if: ${{ contains(inputs.extra-extensions, 'imagick') }}

system/Database/SQLSRV/Forge.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,10 @@ protected function _alterTable(string $alterType, string $table, $processedField
212212

213213
$sql = <<<SQL
214214
SELECT name
215-
FROM SYS.DEFAULT_CONSTRAINTS
216-
WHERE PARENT_OBJECT_ID = OBJECT_ID('{$fullTable}')
217-
AND PARENT_COLUMN_ID IN (
218-
SELECT column_id FROM sys.columns WHERE NAME IN ({$fields}) AND object_id = OBJECT_ID(N'{$fullTable}')
215+
FROM sys.default_constraints
216+
WHERE parent_object_id = OBJECT_ID('{$fullTable}')
217+
AND parent_column_id IN (
218+
SELECT column_id FROM sys.columns WHERE name IN ({$fields}) AND object_id = OBJECT_ID(N'{$fullTable}')
219219
)
220220
SQL;
221221

tests/_support/Database/Migrations/20160428212500_Create_test_tables.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ public function up(): void
9292

9393
if ($this->db->DBDriver === 'SQLSRV') {
9494
unset($dataTypeFields['type_timestamp']);
95+
$dataTypeFields['type_text'] = ['type' => 'NVARCHAR(max)', 'null' => true];
9596
}
9697

9798
if ($this->db->DBDriver === 'Postgre' || $this->db->DBDriver === 'SQLSRV') {

tests/system/Database/Live/ForgeTest.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1615,9 +1615,15 @@ public function testDropKey(): void
16151615
public function testAddTextColumnWithConstraint(): void
16161616
{
16171617
// some DBMS do not allow a constraint for type TEXT
1618-
$this->forge->addColumn('user', [
1619-
'text_with_constraint' => ['type' => 'text', 'constraint' => 255, 'default' => ''],
1620-
]);
1618+
if ($this->db->DBDriver === 'SQLSRV') {
1619+
$this->forge->addColumn('user', [
1620+
'text_with_constraint' => ['type' => 'nvarchar(max)', 'default' => ''],
1621+
]);
1622+
} else {
1623+
$this->forge->addColumn('user', [
1624+
'text_with_constraint' => ['type' => 'text', 'constraint' => 255, 'default' => ''],
1625+
]);
1626+
}
16211627

16221628
$this->assertTrue($this->db->fieldExists('text_with_constraint', 'user'));
16231629

tests/system/Database/Live/GetTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ public function testGetFieldData(): void
178178
$this->assertSame('int', $typeTest[0]->type_name); // INTEGER AUTOINC
179179
$this->assertSame('varchar', $typeTest[1]->type_name); // VARCHAR
180180
$this->assertSame('char', $typeTest[2]->type_name); // CHAR
181-
$this->assertSame('text', $typeTest[3]->type_name); // TEXT
181+
$this->assertSame('nvarchar', $typeTest[3]->type_name); // TEXT
182182
$this->assertSame('smallint', $typeTest[4]->type_name); // SMALLINT
183183
$this->assertSame('int', $typeTest[5]->type_name); // INTEGER
184184
$this->assertSame('float', $typeTest[6]->type_name); // FLOAT

tests/system/Database/Live/LikeTest.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,6 @@ public function testLikeCaseInsensitive(): void
7979
#[DataProvider('provideMultibyteCharacters')]
8080
public function testLikeCaseInsensitiveWithMultibyteCharacter(string $match, string $result): void
8181
{
82-
if ($this->db->DBDriver === 'SQLSRV') {
83-
$this->markTestSkipped(
84-
'Currently Builder class does not fully support Unicode strings in SQLSRV.'
85-
);
86-
}
87-
8882
$wai = $this->db->table('without_auto_increment')->like('value', $match, 'both', null, true)->get();
8983
$wai = $wai->getRow();
9084

0 commit comments

Comments
 (0)