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
2 changes: 1 addition & 1 deletion Plugins/PostgreSQLDriverPlugin/PostgreSQLPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading