File tree Expand file tree Collapse file tree 4 files changed +0
-42
lines changed Expand file tree Collapse file tree 4 files changed +0
-42
lines changed Original file line number Diff line number Diff line change @@ -182,9 +182,6 @@ public extension Query {
182182 isolation: isolated ( any ModelActor ) = #isolation,
183183 body: ( ) -> T
184184 ) throws -> T {
185- guard predicate != nil else {
186- throw Error . missingPredicate
187- }
188185 if let found = try first ( ) {
189186 return found
190187 } else {
Original file line number Diff line number Diff line change @@ -123,9 +123,6 @@ public extension Query {
123123 in container: ModelContainer ,
124124 body: ( ) -> T
125125 ) throws -> T {
126- guard predicate != nil else {
127- throw Error . missingPredicate
128- }
129126 guard let found = try first ( in: container) else {
130127 let created = body ( )
131128 container. mainContext. insert ( created)
@@ -150,18 +147,3 @@ public extension Query {
150147 }
151148 }
152149}
153-
154- public extension Query {
155- /// Errors that can occur during query execution.
156- enum Error : Swift . Error , LocalizedError {
157- /// Thrown when `findOrCreate` is called on a query without a predicate.
158- case missingPredicate
159-
160- public var errorDescription : String ? {
161- switch self {
162- case . missingPredicate:
163- return " Cannot use findOrCreate without a predicate. Add include() or exclude() to specify which object to find. "
164- }
165- }
166- }
167- }
Original file line number Diff line number Diff line change @@ -196,18 +196,6 @@ struct ConcurrentFetchTests {
196196 }
197197 }
198198
199- @Test func findOrCreate_failsWithoutPredicate( ) async throws {
200- _ = await modelContainer. createQueryActor ( ) . perform { actor in
201- #expect( throws: Query < Person > . Error. missingPredicate, performing: {
202- try Person
203- . findOrCreate (
204- isolation: actor ,
205- body: { Person ( name: " Ramona " , age: 99 ) }
206- )
207- } )
208- }
209- }
210-
211199 @Test func findOrCreate_finds( ) async throws {
212200 let foundAge = try await modelContainer. createQueryActor ( ) . perform { _ in
213201 let person = try Person
Original file line number Diff line number Diff line change @@ -165,15 +165,6 @@ struct FetchTests {
165165 #expect( results. last? . name == " Jack " )
166166 }
167167
168- @Test func findOrCreate_failsWithoutPredicate( ) throws {
169- #expect( throws: Query < Person > . Error. missingPredicate, performing: {
170- try Person
171- . findOrCreate ( in: modelContainer) {
172- Person ( name: " Ramona " , age: 99 )
173- }
174- } )
175- }
176-
177168 @Test func findOrCreate_finds( ) throws {
178169 let ramona = try Person
179170 . include ( #Predicate { $0. name == " Ramona " } )
You can’t perform that action at this time.
0 commit comments