Repository navigation
Conversation
J2TeamNNL
left a comment
There was a problem hiding this comment.
Automated code review: 7 findings, inline.
| \(rangeMultirange) AS range_multirange, | ||
| pg_catalog.quote_ident(n.nspname) || '.' || pg_catalog.quote_ident(t.typname) AS spelling | ||
| pg_catalog.quote_ident(n.nspname) || '.' || pg_catalog.quote_ident(t.typname) AS spelling, | ||
| \(domainCheckArray("con.convalidated::text")) AS constraint_validated |
There was a problem hiding this comment.
con.convalidated is selected unconditionally, but that pg_constraint column only exists from PostgreSQL 9.2. On PG 9.1 or older domainCheckArray("con.convalidated::text") raises "column does not exist", so every type listing and fetchUserDefinedType fails and Types vanishes from the sidebar. Gate it with capabilities.hasDomainConstraintValidation and select NULL::text otherwise.
| ) async throws { | ||
| guard let statements = try await statements(for: definition, in: scope), !statements.isEmpty else { | ||
| throw DatabaseObjectCommandError.unsupported | ||
| } |
There was a problem hiding this comment.
Create runs CREATE ... and COMMENT ON ... as separate statements. On a non-transactional route, a failing COMMENT (e.g. no permission) leaves the type created while the call throws. The sheet stays open, and pressing Create again fails with "already exists".
| static func build( | ||
| type: UserDefinedTypeInfo, | ||
| changes: [StagedTypeChange], | ||
| driver: DatabaseDriver |
There was a problem hiding this comment.
UserTypeChangePlan.build relies on the editor keeping a rename last. Every step addresses the type by its old name, so any caller building .rename followed by another change emits statements against a name that no longer exists. Enforce or sort the rename last in build.
| } | ||
|
|
||
| func remove(_ changeId: UUID) { | ||
| changes.removeAll { $0.id == changeId } |
There was a problem hiding this comment.
restoresServerValue compares a rename without trimming, and UserTypeDraft.nonEmpty returns the untrimmed value. " orders_t" passes validation and runs RENAME TO " orders_t", creating a leading-space identifier. Trim before comparing and queuing.
| var next = changes | ||
| if let property = staged.property { | ||
| for replaced in next where replaced.property == property { | ||
| serverErrors.removeValue(forKey: replaced.id) |
There was a problem hiding this comment.
When a property edit restores the server value, stage() returns early without clearing saveSummary, so a previous partial-failure banner stays visible next to the shrunken queue.
| let result = try await DatabaseManager.shared.withScopedDriver( | ||
| scope: scope, | ||
| route: route, | ||
| cancellation: .protectedWrite |
There was a problem hiding this comment.
History records every statement in ran as successful, including statements of a step that failed partway. applied excludes that step, so it stays queued while the server holds half of it (non-transactional route), and replaying can hit duplicate conflicts.
| func generateRenameEnumLabelSQL(type: PluginUserDefinedTypeInfo, from oldLabel: String, to newLabel: String) -> String? | ||
| func generateDropTypeSQL(type: PluginUserDefinedTypeInfo) -> String? | ||
|
|
||
| /// The statements that create a type. Nil for a kind the engine cannot create from a statement, |
There was a problem hiding this comment.
Four new requirements are added to the public PluginDatabaseDriver protocol and PluginUserDefinedTypeChange crosses the plugin boundary, with no PluginKit version bump in the diff. If the version check is how incompatible third-party drivers are rejected, a bump may be needed. Not confirmed.
|
Follow-up to the review, fixes on a fork branch (swiftlint could not run locally, no build was done):
To take the fix: |
Summary
Cmd+Shift+P) and Save Changes (Cmd+S, toolbar commit control), through Safe Mode.PluginUserDefinedTypeInfocarries comment, default, NOT NULL and constraints;PluginUserDefinedTypeChange,PluginUserDefinedTypeDefinition;alterUserDefinedTypeStatements,createUserDefinedTypeStatements,generateDropTypeSQL(type:cascade:),userDefinedTypeChangeRunsOutsideTransaction.PostgreSQLTypeStatementsbuilds every statement; the listing readsconvalidated.CREATE DOMAIN … NOT VALIDdefinition that does not parse; it now follows asALTER DOMAIN … ADD CONSTRAINT … NOT VALID.DatabaseTreeMenuSpecTests(Types sections offered only Refresh),PostgreSQLTypeQueryTests.projectionOrderMatchesParser(newconstraint_validatedcolumn),UserTypeDroppingTests(adapter takescascade:).Test plan
PostgreSQLTypeStatementsTests,UserTypeDraftTests,UserTypeChangeRunnerTests,UserTypeEditorModelTests,UserTypeTabStateTests,DatabaseObjectRefIdentityTests, plus cases inPostgreSQLTypeDefinitionTests,DatabaseTreeMenuSpecTests,ToolbarContextResolverTests,TriggerStructTests,UserTypeDroppingTests.apple/scripts/probes/check-postgres-type-editing.shagainst PostgreSQL 11, 13, 14, 15, 16, 17 and 18: every create, edit, refusal, rename and drop lands as the catalog reports it, and every shown definition rebuilds the same type.verify.shbuild, test, plugins, abi (additive, kit 40), ios, lint, l10n.Offscreen renders of the tab with a queue (the hosting view, no window chrome):
Fixes #3606