Skip to content

Commit

Permalink
Make nil decoding handling for SQLiteRows consistent with the other d…
Browse files Browse the repository at this point in the history
…rivers (#106)

* Make decodeNil handling consistent with the other drivers
* Bump CI
* Fix tests
  • Loading branch information
gwynne authored Oct 18, 2023
1 parent 5caea7d commit b476669
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
dependents-check:
if: ${{ !(github.event.pull_request.draft || false) }}
runs-on: ubuntu-latest
container: swift:5.8-jammy
container: swift:5.9-jammy
steps:
- name: Check out package
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion Sources/SQLiteKit/SQLiteRow+SQLRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ extension SQLiteRow: SQLRow {

public func decodeNil(column: String) throws -> Bool {
guard let data = self.column(column) else {
throw MissingColumn(column: column)
return true
}
return data == .null
}
Expand Down
4 changes: 2 additions & 2 deletions Tests/SQLiteKitTests/SQLiteKitTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,13 @@ final class SQLiteKitTests: XCTestCase {
XCTAssertEqual(try row1.decode(column: "value", as: String?.self), "abc")
XCTAssertThrowsError(try row1.decode(column: "value", as: Int.self))
XCTAssertThrowsError(try row1.decode(column: "nonexistent", as: String?.self))
XCTAssertThrowsError(try row1.decodeNil(column: "nonexistent"))
XCTAssertTrue(try row1.decodeNil(column: "nonexistent"))
XCTAssertTrue(row2.contains(column: "value"))
XCTAssertTrue(try row2.decodeNil(column: "value"))
XCTAssertEqual(try row2.decode(column: "value", as: String?.self), nil)
XCTAssertThrowsError(try row2.decode(column: "value", as: Int.self))
XCTAssertThrowsError(try row2.decode(column: "nonexistent", as: String?.self))
XCTAssertThrowsError(try row2.decodeNil(column: "nonexistent"))
XCTAssertTrue(try row2.decodeNil(column: "nonexistent"))
}

func testRowEncoding() async throws {
Expand Down

0 comments on commit b476669

Please sign in to comment.