Skip to content

@Selection field name is incorrect within update #232

@rcarver

Description

@rcarver

Description

When reading the name of a field during an update, the field name uses the selection's name, not the root table name.

Here's a test that should show it:

@Test func updatesOnSelection() {
  assertQuery(
    Root.update { $0.field.updateSelf() }
  )
  // UPDATE "roots"
  // SET "one" = "fields"."one" ❌ 
}

@Table
struct Root {
  @Columns var field: Field
}

@Selection
struct Field {
  var one: Int
}

extension Updates<Field> {
  mutating func updateSelf() {
    self.one = self.one
  }
}

Side note: I can't run tests or would have taken a try to PR already:

swift-structured-queries/Tests/StructuredQueriesMacrosTests/BindMacroTests.swift:2:8: error: missing required module 'SwiftCompilerPlugin'
 1 | import MacroTesting
 2 | import StructuredQueriesMacros
   |        `- error: missing required module 'SwiftCompilerPlugin'
 3 | import Testing

Checklist

  • I have determined whether this bug is also reproducible in a vanilla SwiftUI project.
  • If possible, I've reproduced the issue using the main branch of this package.
  • This issue hasn't been addressed in an existing GitHub issue or discussion.

Expected behavior

No response

Actual behavior

No response

Reproducing project

No response

Structured Queries version information

f035565

Destination operating system

No response

Xcode version information

Version 26.1 (17B55)

Swift Compiler version information

swift-driver version: 1.127.14.1 Apple Swift version 6.2.1 (swiftlang-6.2.1.4.8 clang-1700.4.4.1)
Target: arm64-apple-macosx15.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions