Skip to content

Commit 04ebb8e

Browse files
Yovachgreg0ire
authored andcommitted
Fix condition on Ascii String for SQL Server
fixed is always set (to either true or false).
1 parent a5d2baf commit 04ebb8e

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

src/Platforms/SQLServerPlatform.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1306,7 +1306,7 @@ public function getAsciiStringTypeDeclarationSQL(array $column): string
13061306
{
13071307
$length = $column['length'] ?? null;
13081308

1309-
if (! isset($column['fixed'])) {
1309+
if (empty($column['fixed'])) {
13101310
return sprintf('VARCHAR(%d)', $length ?? 255);
13111311
}
13121312

tests/Platforms/SQLServerPlatformTest.php

+38
Original file line numberDiff line numberDiff line change
@@ -123,17 +123,55 @@ public function testGeneratesTypeDeclarationsForStrings(): void
123123
'NVARCHAR(50)',
124124
$this->platform->getStringTypeDeclarationSQL(['length' => 50]),
125125
);
126+
self::assertEquals(
127+
'NVARCHAR(50)',
128+
$this->platform->getStringTypeDeclarationSQL(
129+
['length' => 50, 'fixed' => false],
130+
),
131+
);
126132
self::assertEquals(
127133
'NVARCHAR(255)',
128134
$this->platform->getStringTypeDeclarationSQL([]),
129135
);
136+
self::assertEquals(
137+
'NVARCHAR(255)',
138+
$this->platform->getStringTypeDeclarationSQL(['fixed' => false]),
139+
);
130140
self::assertSame('VARCHAR(MAX)', $this->platform->getClobTypeDeclarationSQL([]));
131141
self::assertSame(
132142
'VARCHAR(MAX)',
133143
$this->platform->getClobTypeDeclarationSQL(['length' => 5, 'fixed' => true]),
134144
);
135145
}
136146

147+
public function testGeneratesTypeDeclarationsForAsciiStrings(): void
148+
{
149+
self::assertEquals(
150+
'CHAR(10)',
151+
$this->platform->getAsciiStringTypeDeclarationSQL(
152+
['length' => 10, 'fixed' => true],
153+
),
154+
);
155+
self::assertEquals(
156+
'VARCHAR(50)',
157+
$this->platform->getAsciiStringTypeDeclarationSQL(['length' => 50]),
158+
);
159+
self::assertEquals(
160+
'VARCHAR(50)',
161+
$this->platform->getAsciiStringTypeDeclarationSQL(
162+
['length' => 50, 'fixed' => false],
163+
),
164+
);
165+
self::assertEquals(
166+
'VARCHAR(255)',
167+
$this->platform->getAsciiStringTypeDeclarationSQL([]),
168+
);
169+
self::assertEquals(
170+
'VARCHAR(255)',
171+
$this->platform->getAsciiStringTypeDeclarationSQL(['fixed' => false]),
172+
);
173+
}
174+
137175
public function testPrefersIdentityColumns(): void
138176
{
139177
self::assertTrue($this->platform->prefersIdentityColumns());

0 commit comments

Comments
 (0)