Description
👟 Reproduction steps
When I attempt to perform a simple query operation which includes a select
, the Appwrite code crashes
The setup is very simple; there's a collection of Books as shown in the documentation. Each Book has two properties, title and author (again per the documentation).
The query is for document title
matching Book A
and I want to return only the title and author properties. (yes, I know that's the only two but for this report it demonstrates the bug)
If in the below code the queries
section is removed OR the select
statement is removed, the query works properly.
The code:
func outputSampleBooks() async throws {
do {
let documentList = try await databases.listDocuments(
databaseId: databaseId,
collectionId: collectionId,
queries: [
Query.equal("title", value: "Book A"),
Query.select(["title", "author"])
]
)
} catch {
print(error)
}
}
The books collection is attached below
and then the crash:
AppwriteModels/Document.swift:94: Fatal error: Unexpectedly found nil while unwrapping an Optional value
The crash is located in AppwriteModels->DocumentList.swift->from(map:)
public static func from(map: [String: Any] ) -> DocumentList {
return DocumentList(
total: map["total"] as! Int,
documents: (map["documents"] as! [[String: Any]]).map { Document.from(map: $0) } //crash
)
}
👍 Expected behavior
It should... not crash
👎 Actual Behavior
It actually crashes whenever the query includes a select statement
🎲 Appwrite version
Different version (specify in environment)
💻 Operating system
Linux
🧱 Your Environment
AppWrite sdk-for-apple 9.0.1
XCode 16
macOS Sequoia 15.5
I've duplicated this on several workstations with similar setups
👀 Have you spent some time to check if this issue has been raised before?
- I checked and didn't find similar issue
🏢 Have you read the Code of Conduct?
- I have read the Code of Conduct