File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -133,12 +133,20 @@ protected function _getPortableTableColumnDefinition($tableColumn)
133
133
134
134
switch ($ dbType ) {
135
135
case 'nchar ' :
136
- case 'nvarchar ' :
137
136
case 'ntext ' :
138
137
// Unicode data requires 2 bytes per character
139
138
$ length /= 2 ;
140
139
break ;
141
140
141
+ case 'nvarchar ' :
142
+ if ($ length === -1 ) {
143
+ break ;
144
+ }
145
+
146
+ // Unicode data requires 2 bytes per character
147
+ $ length /= 2 ;
148
+ break ;
149
+
142
150
case 'varchar ' :
143
151
// TEXT type is returned as VARCHAR(MAX) with a length of -1
144
152
if ($ length === -1 ) {
Original file line number Diff line number Diff line change @@ -262,4 +262,19 @@ public function testPkOrdering(): void
262
262
self ::assertEquals ('colB ' , $ columns [0 ]);
263
263
self ::assertEquals ('colA ' , $ columns [1 ]);
264
264
}
265
+
266
+ public function testNvarcharMaxIsLengthMinus1 (): void
267
+ {
268
+ $ sql = 'CREATE TABLE test_nvarchar_max (
269
+ col_nvarchar_max NVARCHAR(MAX),
270
+ col_nvarchar NVARCHAR(128)
271
+ ) ' ;
272
+
273
+ $ this ->connection ->executeStatement ($ sql );
274
+
275
+ $ table = $ this ->schemaManager ->introspectTable ('test_nvarchar_max ' );
276
+
277
+ self ::assertSame (-1 , $ table ->getColumn ('col_nvarchar_max ' )->getLength ());
278
+ self ::assertSame (128 , $ table ->getColumn ('col_nvarchar ' )->getLength ());
279
+ }
265
280
}
You can’t perform that action at this time.
0 commit comments