-
Notifications
You must be signed in to change notification settings - Fork 62
Support for draft identifiers #268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -299,3 +299,31 @@ extension Delete where From: TableDraft { | |
| self.where { $0.primaryKey.in(primaryKeys) } | ||
| } | ||
| } | ||
|
|
||
| import Foundation | ||
| public struct _DraftIdentifier: Hashable, CustomReflectable, Sendable { | ||
| public let rawValue: UUID | ||
| public init() { | ||
| rawValue = UUID() | ||
| } | ||
| public static func == (lhs: Self, rhs: Self) -> Bool { | ||
| true | ||
| } | ||
| public func hash(into hasher: inout Hasher) { | ||
| } | ||
| public var customMirror: Mirror { | ||
| Mirror(self, children: []) | ||
| } | ||
| } | ||
| public struct DraftIdentifier: Hashable, Sendable { | ||
| private let rawValue: _DraftIdentifier | ||
| public init(_ draftIdentifier: _DraftIdentifier) { | ||
| rawValue = draftIdentifier | ||
| } | ||
| public static func == (lhs: Self, rhs: Self) -> Bool { | ||
| lhs.rawValue.rawValue == rhs.rawValue.rawValue | ||
| } | ||
| public func hash(into hasher: inout Hasher) { | ||
| hasher.combine(rawValue.rawValue) | ||
| } | ||
| } | ||
|
Comment on lines
+304
to
+329
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -810,6 +810,10 @@ extension TableMacro: ExtensionMacro { | |||||||||||||||||
| \(draftProperties, separator: "\n") | ||||||||||||||||||
| \(memberBlocks, separator: "\n") | ||||||||||||||||||
| \(memberwiseInit) | ||||||||||||||||||
| private let _draftIdentifier = _DraftIdentifier() | ||||||||||||||||||
| public var draftIdentifier: some Hashable { | ||||||||||||||||||
| DraftIdentifier(_draftIdentifier) | ||||||||||||||||||
|
||||||||||||||||||
| DraftIdentifier(_draftIdentifier) | |
| DraftIdentifier(_draftIdentifier) |
Copilot
AI
Feb 4, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The generated code references _DraftIdentifier and DraftIdentifier without module qualification. These types are defined in StructuredQueriesCore, so they should be qualified as \(moduleName)._DraftIdentifier() and \(moduleName).DraftIdentifier(_draftIdentifier) to be consistent with how other types from the core module are referenced (e.g., \(moduleName).TableDraft on line 808).
Copilot
AI
Feb 4, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The generated code references _DraftIdentifier and DraftIdentifier without module qualification. These types are defined in StructuredQueriesCore, so they should be qualified as \(moduleName)._DraftIdentifier() and \(moduleName).DraftIdentifier(_draftIdentifier) to be consistent with how other types from the core module are referenced (e.g., \(moduleName).TableDraft on line 1402).
| private let _draftIdentifier = _DraftIdentifier() | |
| public var draftIdentifier: some Hashable { | |
| DraftIdentifier(_draftIdentifier) | |
| private let _draftIdentifier = \(moduleName)._DraftIdentifier() | |
| public var draftIdentifier: some Hashable { | |
| \(moduleName).DraftIdentifier(_draftIdentifier) |
Copilot
AI
Feb 4, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The body of the draftIdentifier computed property is not indented. The line DraftIdentifier(_draftIdentifier) should be indented to match the formatting of other generated code. This should be DraftIdentifier(_draftIdentifier) (with 2 spaces of indentation) to match the expected code style shown in the test snapshots.
| DraftIdentifier(_draftIdentifier) | |
| DraftIdentifier(_draftIdentifier) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
import Foundationstatement is placed mid-file, immediately before the types that useUUID. While this works, it's more conventional in Swift to place all imports at the top of the file for better readability and consistency with the rest of the codebase. Consider moving this import to the top of the file.