Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
michalsn committed Dec 23, 2024
1 parent 55a27d1 commit eeadef2
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 10 deletions.
2 changes: 1 addition & 1 deletion system/Database/BasePreparedQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public function getErrorMessage(): string
/**
* Whether the input contain binary data.
*/
protected function isBinary($input): bool
protected function isBinary(string $input): bool
{
return mb_detect_encoding($input, 'UTF-8', true) === false;
}
Expand Down
6 changes: 5 additions & 1 deletion system/Database/SQLSRV/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,11 @@ protected function _fieldData(string $table): array

$retVal[$i]->max_length = $query[$i]->CHARACTER_MAXIMUM_LENGTH > 0
? $query[$i]->CHARACTER_MAXIMUM_LENGTH
: $query[$i]->NUMERIC_PRECISION;
: (
$query[$i]->CHARACTER_MAXIMUM_LENGTH === -1
? 'max'
: $query[$i]->NUMERIC_PRECISION
);

$retVal[$i]->nullable = $query[$i]->IS_NULLABLE !== 'NO';
$retVal[$i]->default = $query[$i]->COLUMN_DEFAULT;
Expand Down
2 changes: 1 addition & 1 deletion system/Database/SQLSRV/Forge.php
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ protected function _attributeType(array &$attributes)
break;

case 'BLOB':
$attributes['TYPE'] = 'VARBINARY';
$attributes['TYPE'] = 'VARBINARY';
$attributes['CONSTRAINT'] ??= 'MAX';
break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function up(): void
}

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

Expand Down
10 changes: 4 additions & 6 deletions tests/system/Database/Live/AbstractGetFieldDataTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ protected function createTableForType(): void
$this->forge->dropTable($this->table, true);

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

if ($this->db->DBDriver === 'SQLSRV') {
unset(
$fields['type_set'],
$fields['type_mediumtext'],
$fields['type_double'],
$fields['type_blob']
$fields['type_double']
);
}

Expand Down
7 changes: 7 additions & 0 deletions tests/system/Database/Live/Postgre/GetFieldDataTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,13 @@ public function testGetFieldDataType(): void
'default' => null,
],
15 => (object) [
'name' => 'type_blob',
'type' => 'bytea',
'max_length' => null,
'nullable' => true,
'default' => null,
],
16 => (object) [
'name' => 'type_boolean',
'type' => 'boolean',
'max_length' => null,
Expand Down
7 changes: 7 additions & 0 deletions tests/system/Database/Live/SQLSRV/GetFieldDataTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,13 @@ public function testGetFieldDataType(): void
'default' => null,
],
16 => (object) [
'name' => 'type_blob',
'type' => 'varbinary',
'max_length' => 'max',
'nullable' => true,
'default' => null,
],
17 => (object) [
'name' => 'type_boolean',
'type' => 'bit',
'max_length' => null,
Expand Down

0 comments on commit eeadef2

Please sign in to comment.