Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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 Examples/CaseStudies/ObservableModelDemo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import SwiftUI

struct ObservableModelDemo: SwiftUICaseStudy {
let readMe = """
This demonstrates how to use the `@FetchAll` and `@FetchOne` tools in an @Observable model. \
This demonstrates how to use the `@FetchAll` and `@FetchOne` tools in an `@Observable` model. \
In SwiftUI, the `@Query` macro only works when installed directly in a SwiftUI view, and \
cannot be used outside of views.

Expand Down
8 changes: 8 additions & 0 deletions Examples/Reminders/SearchReminders.swift
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,14 @@ class SearchRemindersModel {
.fetchAll(db)
)
}
static func == (lhs: Self, rhs: Self) -> Bool {
lhs.baseQuery.query == rhs.baseQuery.query
&& lhs.showCompletedInSearchResults == rhs.showCompletedInSearchResults
}
func hash(into hasher: inout Hasher) {
hasher.combine(baseQuery.query)
hasher.combine(showCompletedInSearchResults)
}
}

struct Token: Hashable, Identifiable {
Expand Down
13 changes: 2 additions & 11 deletions Sources/SQLiteData/Internal/StatementKey.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,10 @@ protocol StatementKeyRequest<QueryValue>: FetchKeyRequest {

extension StatementKeyRequest {
static func == (lhs: Self, rhs: Self) -> Bool {
// NB: A Swift 6.1 regression prevents this from compiling:
// https://github.com/swiftlang/swift/issues/79623
// return AnyHashable(lhs.statement) == AnyHashable(rhs.statement)
let lhs = lhs.statement
let rhs = rhs.statement
return AnyHashable(lhs) == AnyHashable(rhs)
lhs.statement.query == rhs.statement.query
}

func hash(into hasher: inout Hasher) {
// NB: A Swift 6.1 regression prevents this from compiling:
// https://github.com/swiftlang/swift/issues/79623
// hasher.combine(statement)
let statement = statement
hasher.combine(statement)
hasher.combine(statement.query)
}
}