Skip to content

Commit

Permalink
Driver::getColumns() nativeType is not upper
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Aug 18, 2024
1 parent 74feca4 commit 6d6d088
Show file tree
Hide file tree
Showing 11 changed files with 140 additions and 140 deletions.
2 changes: 1 addition & 1 deletion src/Database/Drivers/Engines/MSSQLEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public function getColumns(string $table): array
$columns[] = [
'name' => $row['COLUMN_NAME'],
'table' => $table,
'nativeType' => strtoupper($row['DATA_TYPE']),
'nativeType' => $row['DATA_TYPE'],
'size' => $row['CHARACTER_MAXIMUM_LENGTH'] ?? ($row['NUMERIC_PRECISION'] ?? null),
'unsigned' => false,
'nullable' => $row['IS_NULLABLE'] === 'YES',
Expand Down
2 changes: 1 addition & 1 deletion src/Database/Drivers/Engines/MySQLEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public function getColumns(string $table): array
$columns[] = [
'name' => $row['field'],
'table' => $table,
'nativeType' => strtoupper($type[0]),
'nativeType' => $type[0],
'size' => isset($type[1]) ? (int) $type[1] : null,
'nullable' => $row['null'] === 'YES',
'default' => $row['default'],
Expand Down
2 changes: 1 addition & 1 deletion src/Database/Drivers/Engines/PostgreSQLEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public function getColumns(string $table): array
SELECT
a.attname::varchar AS name,
c.relname::varchar AS table,
upper(t.typname) AS nativeType,
t.typname AS nativeType,
CASE WHEN a.atttypmod = -1 THEN NULL ELSE a.atttypmod -4 END AS size,
NOT (a.attnotnull OR t.typtype = 'd' AND t.typnotnull) AS nullable,
pg_catalog.pg_get_expr(ad.adbin, 'pg_catalog.pg_attrdef'::regclass)::varchar AS default,
Expand Down
2 changes: 1 addition & 1 deletion src/Database/Drivers/Engines/SQLServerEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public function getColumns(string $table): array
SELECT
c.name AS name,
o.name AS [table],
UPPER(t.name) AS nativeType,
t.name AS nativeType,
NULL AS size,
c.is_nullable AS nullable,
OBJECT_DEFINITION(c.default_object_id) AS [default],
Expand Down
2 changes: 1 addition & 1 deletion src/Database/Drivers/Engines/SQLiteEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public function getColumns(string $table): array
$columns[] = [
'name' => $column,
'table' => $table,
'nativeType' => strtoupper($type[0]),
'nativeType' => $type[0],
'size' => isset($type[1]) ? (int) $type[1] : null,
'nullable' => $row['notnull'] === 0,
'default' => $row['dflt_value'],
Expand Down
58 changes: 29 additions & 29 deletions tests/Database/Reflection.columns.mysql.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ $expectedColumns = [
'unsigned_int' => [
'name' => 'unsigned_int',
'table' => 'types',
'nativeType' => 'INT',
'nativeType' => 'int',
'size' => $version80 ? null : 11,
'nullable' => true,
'default' => null,
Expand All @@ -33,7 +33,7 @@ $expectedColumns = [
'int' => [
'name' => 'int',
'table' => 'types',
'nativeType' => 'INT',
'nativeType' => 'int',
'size' => $version80 ? null : 11,
'nullable' => true,
'default' => null,
Expand All @@ -43,7 +43,7 @@ $expectedColumns = [
'smallint' => [
'name' => 'smallint',
'table' => 'types',
'nativeType' => 'SMALLINT',
'nativeType' => 'smallint',
'size' => $version80 ? null : 6,
'nullable' => true,
'default' => null,
Expand All @@ -53,7 +53,7 @@ $expectedColumns = [
'tinyint' => [
'name' => 'tinyint',
'table' => 'types',
'nativeType' => 'TINYINT',
'nativeType' => 'tinyint',
'size' => $version80 ? null : 4,
'nullable' => true,
'default' => null,
Expand All @@ -63,7 +63,7 @@ $expectedColumns = [
'mediumint' => [
'name' => 'mediumint',
'table' => 'types',
'nativeType' => 'MEDIUMINT',
'nativeType' => 'mediumint',
'size' => $version80 ? null : 9,
'nullable' => true,
'default' => null,
Expand All @@ -73,7 +73,7 @@ $expectedColumns = [
'bigint' => [
'name' => 'bigint',
'table' => 'types',
'nativeType' => 'BIGINT',
'nativeType' => 'bigint',
'size' => $version80 ? null : 20,
'nullable' => true,
'default' => null,
Expand All @@ -83,7 +83,7 @@ $expectedColumns = [
'bool' => [
'name' => 'bool',
'table' => 'types',
'nativeType' => 'TINYINT',
'nativeType' => 'tinyint',
'size' => 1,
'nullable' => true,
'default' => null,
Expand All @@ -93,7 +93,7 @@ $expectedColumns = [
'bit' => [
'name' => 'bit',
'table' => 'types',
'nativeType' => 'BIT',
'nativeType' => 'bit',
'size' => 1,
'nullable' => true,
'default' => null,
Expand All @@ -103,7 +103,7 @@ $expectedColumns = [
'decimal' => [
'name' => 'decimal',
'table' => 'types',
'nativeType' => 'DECIMAL',
'nativeType' => 'decimal',
'size' => 10,
'nullable' => true,
'default' => null,
Expand All @@ -113,7 +113,7 @@ $expectedColumns = [
'decimal2' => [
'name' => 'decimal2',
'table' => 'types',
'nativeType' => 'DECIMAL',
'nativeType' => 'decimal',
'size' => 10,
'nullable' => true,
'default' => null,
Expand All @@ -123,7 +123,7 @@ $expectedColumns = [
'float' => [
'name' => 'float',
'table' => 'types',
'nativeType' => 'FLOAT',
'nativeType' => 'float',
'size' => null,
'nullable' => true,
'default' => null,
Expand All @@ -133,7 +133,7 @@ $expectedColumns = [
'double' => [
'name' => 'double',
'table' => 'types',
'nativeType' => 'DOUBLE',
'nativeType' => 'double',
'size' => null,
'nullable' => true,
'default' => null,
Expand All @@ -143,7 +143,7 @@ $expectedColumns = [
'date' => [
'name' => 'date',
'table' => 'types',
'nativeType' => 'DATE',
'nativeType' => 'date',
'size' => null,
'nullable' => true,
'default' => null,
Expand All @@ -153,7 +153,7 @@ $expectedColumns = [
'time' => [
'name' => 'time',
'table' => 'types',
'nativeType' => 'TIME',
'nativeType' => 'time',
'size' => null,
'nullable' => true,
'default' => null,
Expand All @@ -163,7 +163,7 @@ $expectedColumns = [
'datetime' => [
'name' => 'datetime',
'table' => 'types',
'nativeType' => 'DATETIME',
'nativeType' => 'datetime',
'size' => null,
'nullable' => true,
'default' => null,
Expand Down Expand Up @@ -193,7 +193,7 @@ $expectedColumns = [
'char' => [
'name' => 'char',
'table' => 'types',
'nativeType' => 'CHAR',
'nativeType' => 'char',
'size' => 1,
'nullable' => true,
'default' => null,
Expand All @@ -203,7 +203,7 @@ $expectedColumns = [
'varchar' => [
'name' => 'varchar',
'table' => 'types',
'nativeType' => 'VARCHAR',
'nativeType' => 'varchar',
'size' => 30,
'nullable' => true,
'default' => null,
Expand All @@ -213,7 +213,7 @@ $expectedColumns = [
'binary' => [
'name' => 'binary',
'table' => 'types',
'nativeType' => 'BINARY',
'nativeType' => 'binary',
'size' => 1,
'nullable' => true,
'default' => null,
Expand All @@ -223,7 +223,7 @@ $expectedColumns = [
'varbinary' => [
'name' => 'varbinary',
'table' => 'types',
'nativeType' => 'VARBINARY',
'nativeType' => 'varbinary',
'size' => 30,
'nullable' => true,
'default' => null,
Expand All @@ -233,7 +233,7 @@ $expectedColumns = [
'blob' => [
'name' => 'blob',
'table' => 'types',
'nativeType' => 'BLOB',
'nativeType' => 'blob',
'size' => null,
'nullable' => true,
'default' => null,
Expand All @@ -243,7 +243,7 @@ $expectedColumns = [
'tinyblob' => [
'name' => 'tinyblob',
'table' => 'types',
'nativeType' => 'TINYBLOB',
'nativeType' => 'tinyblob',
'size' => null,
'nullable' => true,
'default' => null,
Expand All @@ -253,7 +253,7 @@ $expectedColumns = [
'mediumblob' => [
'name' => 'mediumblob',
'table' => 'types',
'nativeType' => 'MEDIUMBLOB',
'nativeType' => 'mediumblob',
'size' => null,
'nullable' => true,
'default' => null,
Expand All @@ -263,7 +263,7 @@ $expectedColumns = [
'longblob' => [
'name' => 'longblob',
'table' => 'types',
'nativeType' => 'LONGBLOB',
'nativeType' => 'longblob',
'size' => null,
'nullable' => true,
'default' => null,
Expand All @@ -273,7 +273,7 @@ $expectedColumns = [
'text' => [
'name' => 'text',
'table' => 'types',
'nativeType' => 'TEXT',
'nativeType' => 'text',
'size' => null,
'nullable' => true,
'default' => null,
Expand All @@ -283,7 +283,7 @@ $expectedColumns = [
'tinytext' => [
'name' => 'tinytext',
'table' => 'types',
'nativeType' => 'TINYTEXT',
'nativeType' => 'tinytext',
'size' => null,
'nullable' => true,
'default' => null,
Expand All @@ -293,7 +293,7 @@ $expectedColumns = [
'mediumtext' => [
'name' => 'mediumtext',
'table' => 'types',
'nativeType' => 'MEDIUMTEXT',
'nativeType' => 'mediumtext',
'size' => null,
'nullable' => true,
'default' => null,
Expand All @@ -303,7 +303,7 @@ $expectedColumns = [
'longtext' => [
'name' => 'longtext',
'table' => 'types',
'nativeType' => 'LONGTEXT',
'nativeType' => 'longtext',
'size' => null,
'nullable' => true,
'default' => null,
Expand All @@ -313,7 +313,7 @@ $expectedColumns = [
'enum' => [
'name' => 'enum',
'table' => 'types',
'nativeType' => 'ENUM',
'nativeType' => 'enum',
'size' => 0,
'nullable' => true,
'default' => null,
Expand All @@ -323,7 +323,7 @@ $expectedColumns = [
'set' => [
'name' => 'set',
'table' => 'types',
'nativeType' => 'SET',
'nativeType' => 'set',
'size' => 0,
'nullable' => true,
'default' => null,
Expand Down
Loading

0 comments on commit 6d6d088

Please sign in to comment.