Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion system/Database/Postgre/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,16 @@ private function getFieldType(string $table, string $fieldName): ?string
$this->QBOptions['fieldTypes'][$table] = [];

foreach ($this->db->getFieldData($table) as $field) {
$this->QBOptions['fieldTypes'][$table][$field->name] = $field->type;
$type = $field->type;

// If `character` (or `char`) lacks a specifier, it is equivalent
// to `character(1)`.
// See https://www.postgresql.org/docs/current/datatype-character.html
if ($field->type === 'character') {
$type = $field->type . '(' . $field->max_length . ')';
}

$this->QBOptions['fieldTypes'][$table][$field->name] = $type;
}
}

Expand Down
6 changes: 5 additions & 1 deletion tests/system/Database/Live/UpdateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public function testUpdateBatch(string $constraints, array $data, array $expecte
for ($i = 1; $i < 4; $i++) {
$builder->insert([
'type_varchar' => 'test' . $i,
'type_char' => 'char',
'type_char' => 'char' . $i,
'type_text' => 'text',
'type_smallint' => 32767,
'type_integer' => 2_147_483_647,
Expand Down Expand Up @@ -159,6 +159,7 @@ public static function provideUpdateBatch(): iterable
[
[
'type_varchar' => 'test1', // Key
'type_char' => 'updated',
'type_text' => 'updated',
'type_smallint' => 9999,
'type_integer' => 9_999_999,
Expand All @@ -170,6 +171,7 @@ public static function provideUpdateBatch(): iterable
],
[
'type_varchar' => 'test2', // Key
'type_char' => 'updated',
'type_text' => 'updated',
'type_smallint' => 9999,
'type_integer' => 9_999_999,
Expand All @@ -183,6 +185,7 @@ public static function provideUpdateBatch(): iterable
[
[
'type_varchar' => 'test1',
'type_char' => 'updated',
'type_text' => 'updated',
'type_smallint' => 9999,
'type_integer' => 9_999_999,
Expand All @@ -193,6 +196,7 @@ public static function provideUpdateBatch(): iterable
],
[
'type_varchar' => 'test2',
'type_char' => 'updated',
'type_text' => 'updated',
'type_smallint' => 9999,
'type_integer' => 9_999_999,
Expand Down