Skip to content

Throwing row accessors#1796

Merged
groue merged 11 commits intodevelopmentfrom
dev/public-RowDecodingError
Jul 20, 2025
Merged

Throwing row accessors#1796
groue merged 11 commits intodevelopmentfrom
dev/public-RowDecodingError

Conversation

@groue
Copy link
Copy Markdown
Owner

@groue groue commented Jul 20, 2025

This pull requests add a way to catch row decoding errors:

self.name = try row.decode(String.self, atIndex: 0)
self.bookCount = try row.decode(Int.self, forColumn: "bookCount")

The use of those throwing accessors 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.

Throwing accessors can be useful while debugging such an application, as described in #1786.

Other users can profit from the much shorter subscripts:

self.name = row[0]
self.bookCount = row["bookCount"]

@groue groue changed the base branch from master to development July 20, 2025 12:34
@groue groue force-pushed the dev/public-RowDecodingError branch from 06ad3c3 to 6ca38ed Compare July 20, 2025 12:38
@groue groue merged commit b4a21d6 into development Jul 20, 2025
8 checks passed
@groue groue deleted the dev/public-RowDecodingError branch July 20, 2025 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant