Skip to content

Commit

Permalink
Throw error for unsupported predicates
Browse files Browse the repository at this point in the history
  • Loading branch information
colemancda committed Apr 30, 2024
1 parent 925670f commit 7480100
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Sources/MongoDBModel/MongoDatabase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,9 @@ internal extension MongoDatabase {
) async throws -> [BSONDocument] {
let entityName = fetchRequest.entity
let collection = self.collection(entityName, options: options)
let filter = fetchRequest.predicate.flatMap { BSONDocument(predicate: $0) } ?? [:]
guard let filter = fetchRequest.predicate.flatMap({ BSONDocument(predicate: $0) }) else {
throw CocoaError(.featureUnsupported)
}
let options = FindOptions(fetchRequest: fetchRequest)
let stream = try await collection.find(filter, options: options)
var results = [BSONDocument]()
Expand Down

0 comments on commit 7480100

Please sign in to comment.