diff --git a/Plugins/PostgreSQLDriverPlugin/PostgreSQLPlugin.swift b/Plugins/PostgreSQLDriverPlugin/PostgreSQLPlugin.swift index c6b52b320d..66c7a5d67e 100644 --- a/Plugins/PostgreSQLDriverPlugin/PostgreSQLPlugin.swift +++ b/Plugins/PostgreSQLDriverPlugin/PostgreSQLPlugin.swift @@ -92,7 +92,7 @@ final class PostgreSQLPlugin: NSObject, TableProPlugin, DriverPlugin { static let supportsDatabaseTriggerBrowse = true static let supportsTriggerEditing = true static let structureColumnFields: [StructureColumnField] = - [.name, .type, .nullable, .defaultValue, .generated, .generationExpression, .comment] + [.name, .type, .nullable, .defaultValue, .generated, .generationExpression, .autoIncrement, .comment] static let supportsCheckConstraints = true static let supportsCheckConstraintEditing = true diff --git a/TablePro/Core/Plugins/PluginMetadataRegistry+CuratedDefaults.swift b/TablePro/Core/Plugins/PluginMetadataRegistry+CuratedDefaults.swift index 133670e5e2..fbb9ba7b55 100644 --- a/TablePro/Core/Plugins/PluginMetadataRegistry+CuratedDefaults.swift +++ b/TablePro/Core/Plugins/PluginMetadataRegistry+CuratedDefaults.swift @@ -392,7 +392,8 @@ extension PluginMetadataRegistry { fileExtensions: [], databaseGroupingStrategy: .bySchema, structureColumnFields: [ - .name, .type, .nullable, .defaultValue, .generated, .generationExpression, .comment + .name, .type, .nullable, .defaultValue, .generated, .generationExpression, + .autoIncrement, .comment ] ), editor: PluginMetadataSnapshot.EditorConfig( @@ -525,7 +526,8 @@ extension PluginMetadataRegistry { fileExtensions: [], databaseGroupingStrategy: .bySchema, structureColumnFields: [ - .name, .type, .nullable, .defaultValue, .generated, .generationExpression, .comment + .name, .type, .nullable, .defaultValue, .generated, .generationExpression, + .autoIncrement, .comment ] ), editor: PluginMetadataSnapshot.EditorConfig( @@ -589,7 +591,8 @@ extension PluginMetadataRegistry { fileExtensions: [], databaseGroupingStrategy: .bySchema, structureColumnFields: [ - .name, .type, .nullable, .defaultValue, .generated, .generationExpression, .comment + .name, .type, .nullable, .defaultValue, .generated, .generationExpression, + .autoIncrement, .comment ] ), editor: PluginMetadataSnapshot.EditorConfig( diff --git a/TableProTests/Views/Structure/StructureColumnFieldRegistrationTests.swift b/TableProTests/Views/Structure/StructureColumnFieldRegistrationTests.swift index 7db34aaa64..aea38ea9b7 100644 --- a/TableProTests/Views/Structure/StructureColumnFieldRegistrationTests.swift +++ b/TableProTests/Views/Structure/StructureColumnFieldRegistrationTests.swift @@ -45,6 +45,32 @@ struct StructureColumnFieldRegistrationTests { } } + /// Adding the generated-column pair to the Postgres family replaced `.autoIncrement` instead + /// of joining it (#2557), so a `SERIAL` column lost its Auto Increment flag in the structure + /// editor while `PostgreSQLPluginDriver` went on generating the DDL for one. Redshift is in + /// the list as the control: it never gained the generated fields and never lost this one. + @Test( + "The Postgres family offers auto increment beside the generated fields", + arguments: [DatabaseType.postgresql, .cockroachdb, .pglite, .redshift] + ) + func autoIncrementSurvivesTheGeneratedFields(databaseType: DatabaseType) { + #expect(PluginManager.shared.structureColumnFields(for: databaseType).contains(.autoIncrement)) + } + + /// The columns tab reads its dropdown options by looking each boolean field up in the ordered + /// list, so a field the engine stops declaring silently loses its editor rather than failing. + @Test( + "Every boolean field an engine declares resolves to a column", + arguments: [DatabaseType.postgresql, .mysql, .sqlite, .cockroachdb, .pglite] + ) + func declaredBooleanFieldsResolve(databaseType: DatabaseType) { + let ordered = StructureRowProvider.orderedFields(for: databaseType) + let declared = Set(PluginManager.shared.structureColumnFields(for: databaseType)) + for field in [StructureColumnField.nullable, .autoIncrement, .onUpdate] where declared.contains(field) { + #expect(ordered.contains(field), "\(databaseType.rawValue) declares \(field) but cannot order it") + } + } + @Test("Every declared field has a display name") func everyFieldHasDisplayName() { for field in StructureColumnField.allCases {