Skip to content

Commit eeadef2

Browse files
committed
fix tests
1 parent 55a27d1 commit eeadef2

File tree

7 files changed

+26
-10
lines changed

7 files changed

+26
-10
lines changed

system/Database/BasePreparedQuery.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ public function getErrorMessage(): string
263263
/**
264264
* Whether the input contain binary data.
265265
*/
266-
protected function isBinary($input): bool
266+
protected function isBinary(string $input): bool
267267
{
268268
return mb_detect_encoding($input, 'UTF-8', true) === false;
269269
}

system/Database/SQLSRV/Connection.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,11 @@ protected function _fieldData(string $table): array
368368

369369
$retVal[$i]->max_length = $query[$i]->CHARACTER_MAXIMUM_LENGTH > 0
370370
? $query[$i]->CHARACTER_MAXIMUM_LENGTH
371-
: $query[$i]->NUMERIC_PRECISION;
371+
: (
372+
$query[$i]->CHARACTER_MAXIMUM_LENGTH === -1
373+
? 'max'
374+
: $query[$i]->NUMERIC_PRECISION
375+
);
372376

373377
$retVal[$i]->nullable = $query[$i]->IS_NULLABLE !== 'NO';
374378
$retVal[$i]->default = $query[$i]->COLUMN_DEFAULT;

system/Database/SQLSRV/Forge.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ protected function _attributeType(array &$attributes)
398398
break;
399399

400400
case 'BLOB':
401-
$attributes['TYPE'] = 'VARBINARY';
401+
$attributes['TYPE'] = 'VARBINARY';
402402
$attributes['CONSTRAINT'] ??= 'MAX';
403403
break;
404404

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public function up(): void
9191
}
9292

9393
if ($this->db->DBDriver === 'SQLSRV') {
94-
unset($dataTypeFields['type_timestamp'], $dataTypeFields['type_blob']);
94+
unset($dataTypeFields['type_timestamp']);
9595
$dataTypeFields['type_text'] = ['type' => 'NVARCHAR(max)', 'null' => true];
9696
}
9797

tests/system/Database/Live/AbstractGetFieldDataTestCase.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ protected function createTableForType(): void
104104
$this->forge->dropTable($this->table, true);
105105

106106
// missing types:
107-
// TINYINT,MEDIUMINT,BIT,YEAR,BINARY,VARBINARY,TINYTEXT,LONGTEXT,
108-
// JSON,Spatial data types
107+
// TINYINT,MEDIUMINT,BIT,YEAR,BINARY,VARBINARY (BLOB more or less handles these two),
108+
// TINYTEXT,LONGTEXT,JSON,Spatial data types
109109
// `id` must be INTEGER else SQLite3 error on not null for autoincrement field.
110110
$fields = [
111111
'id' => ['type' => 'INTEGER', 'constraint' => 20, 'auto_increment' => true],
@@ -138,17 +138,15 @@ protected function createTableForType(): void
138138
$fields['type_enum'],
139139
$fields['type_set'],
140140
$fields['type_mediumtext'],
141-
$fields['type_double'],
142-
$fields['type_blob']
141+
$fields['type_double']
143142
);
144143
}
145144

146145
if ($this->db->DBDriver === 'SQLSRV') {
147146
unset(
148147
$fields['type_set'],
149148
$fields['type_mediumtext'],
150-
$fields['type_double'],
151-
$fields['type_blob']
149+
$fields['type_double']
152150
);
153151
}
154152

tests/system/Database/Live/Postgre/GetFieldDataTestCase.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,13 @@ public function testGetFieldDataType(): void
212212
'default' => null,
213213
],
214214
15 => (object) [
215+
'name' => 'type_blob',
216+
'type' => 'bytea',
217+
'max_length' => null,
218+
'nullable' => true,
219+
'default' => null,
220+
],
221+
16 => (object) [
215222
'name' => 'type_boolean',
216223
'type' => 'boolean',
217224
'max_length' => null,

tests/system/Database/Live/SQLSRV/GetFieldDataTestCase.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,13 @@ public function testGetFieldDataType(): void
219219
'default' => null,
220220
],
221221
16 => (object) [
222+
'name' => 'type_blob',
223+
'type' => 'varbinary',
224+
'max_length' => 'max',
225+
'nullable' => true,
226+
'default' => null,
227+
],
228+
17 => (object) [
222229
'name' => 'type_boolean',
223230
'type' => 'bit',
224231
'max_length' => null,

0 commit comments

Comments
 (0)