From a46f3b69e9016030dc0bffa21ae2c2cbc22ea17b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Sun, 20 Jul 2025 12:59:04 +0200 Subject: [PATCH] Document throwing row accessors --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 91a2740d5..1f532f370 100644 --- a/README.md +++ b/README.md @@ -843,6 +843,13 @@ row[...] as Int row[...] as Int? ``` +Throwing accessors exist as well. Their use is not encouraged, because a database decoding error is a programming error. If an application stores invalid data in the database file, that is a bug that needs to be fixed: + +```swift +let name = try row.decode(String.self, atIndex: 0) +let bookCount = try row.decode(Int.self, forColumn: "bookCount") +``` + > **Warning**: avoid the `as!` and `as?` operators: > > ```swift