-
Notifications
You must be signed in to change notification settings - Fork 74
Closed
Description
Description
Hi PointFree!
I am migrating one of my smaller apps from using GRDB to SQLiteData, and I wasn't able to set up an update query with a table that has UUID that is byte representation.
@Table("voiceMemo") struct VoiceMemo: Identifiable {
@Column(as: UUID.BytesRepresentation.self) // this is required since GRDB stores UUID in bytes form
let id: UUID
var title: String?
var audioURL: String?
var transcription: String?
var createdAt: Date?
var updatedAt: Date?
}
@Observable class MemoItemViewModel {
@ObservationIgnored @Dependency(\.date.now) private var now
@ObservationIgnored @Dependency(\.defaultDatabase) private var database
var memo: VoiceMemo
var shouldTranscribe: Bool {
memo.createdAt == memo.updatedAt
}
init(memo: VoiceMemo) {
self.memo = memo
}
func touchMemo() throws {
// can only upsert here since the where clause is not working
// TODO: see if there is a way to change the column byte representation
try database.write { db in
try VoiceMemo.update {
$0.updatedAt = now
}.where {
$0.id == memo.id
}
// try VoiceMemo.upsert {
// VoiceMemo.Draft(
// id: memo.id,
// title: memo.title,
// audioURL: memo.audioURL,
// transcription: memo.transcription,
// createdAt: memo.createdAt,
// updatedAt: Date(timeInterval: 1, since: memo.createdAt ?? now)
// )
// }
// .execute(db)
}
}
}
Currently I should be able to just use upserts to get around the issue. But I want to see if there is a way set up the querying properly without doing a big migration of tables. If not I will look into migrating. Happy holidays and thanks!
Checklist
- I have determined whether this bug is also reproducible in a vanilla SwiftUI project.
- I have determined whether this bug is also reproducible in a vanilla GRDB project.
- If possible, I've reproduced the issue using the
mainbranch 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
SQLiteData version information
1.4.0
Sharing version information
2.7.4
GRDB version information
7.9.0
Destination operating system
macOS 26
Xcode version information
XCode 26
Swift Compiler version information
Metadata
Metadata
Assignees
Labels
No labels