Issue #2976493 by tstoeckler, daffie: Creating a table with an explicitly empty primary key is broken on PostgreSQL
parent
0cc5879a8a
commit
c4923ea2a2
|
@ -249,7 +249,7 @@ EOD;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql_keys = [];
|
$sql_keys = [];
|
||||||
if (isset($table['primary key']) && is_array($table['primary key'])) {
|
if (!empty($table['primary key']) && is_array($table['primary key'])) {
|
||||||
$sql_keys[] = 'CONSTRAINT ' . $this->ensureIdentifiersLength($name, '', 'pkey') . ' PRIMARY KEY (' . $this->createPrimaryKeySql($table['primary key']) . ')';
|
$sql_keys[] = 'CONSTRAINT ' . $this->ensureIdentifiersLength($name, '', 'pkey') . ' PRIMARY KEY (' . $this->createPrimaryKeySql($table['primary key']) . ')';
|
||||||
}
|
}
|
||||||
if (isset($table['unique keys']) && is_array($table['unique keys'])) {
|
if (isset($table['unique keys']) && is_array($table['unique keys'])) {
|
||||||
|
|
|
@ -1009,7 +1009,7 @@ class SchemaTest extends KernelTestBase {
|
||||||
$this->assertSame(['id3', 'test_field_2', 'id4'], $method->invoke($schema, 'table_with_pk_3'));
|
$this->assertSame(['id3', 'test_field_2', 'id4'], $method->invoke($schema, 'table_with_pk_3'));
|
||||||
|
|
||||||
// Test with table without a primary key.
|
// Test with table without a primary key.
|
||||||
$schema->createTable('table_without_pk', [
|
$schema->createTable('table_without_pk_1', [
|
||||||
'description' => 'Table without primary key.',
|
'description' => 'Table without primary key.',
|
||||||
'fields' => [
|
'fields' => [
|
||||||
'id' => [
|
'id' => [
|
||||||
|
@ -1022,7 +1022,24 @@ class SchemaTest extends KernelTestBase {
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
$this->assertSame([], $method->invoke($schema, 'table_without_pk'));
|
$this->assertSame([], $method->invoke($schema, 'table_without_pk_1'));
|
||||||
|
|
||||||
|
// Test with table with an empty primary key.
|
||||||
|
$schema->createTable('table_without_pk_2', [
|
||||||
|
'description' => 'Table without primary key.',
|
||||||
|
'fields' => [
|
||||||
|
'id' => [
|
||||||
|
'type' => 'int',
|
||||||
|
'not null' => TRUE,
|
||||||
|
],
|
||||||
|
'test_field' => [
|
||||||
|
'type' => 'int',
|
||||||
|
'not null' => TRUE,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'primary key' => [],
|
||||||
|
]);
|
||||||
|
$this->assertSame([], $method->invoke($schema, 'table_without_pk_2'));
|
||||||
|
|
||||||
// Test with non existing table.
|
// Test with non existing table.
|
||||||
$this->assertFalse($method->invoke($schema, 'non_existing_table'));
|
$this->assertFalse($method->invoke($schema, 'non_existing_table'));
|
||||||
|
|
Loading…
Reference in New Issue