Skip to content

Commit

Permalink
Sending empty subscription before completion in case of initializatio…
Browse files Browse the repository at this point in the history
…n error. Removed repeated completion on deinitialization of subscription.
  • Loading branch information
DnV1eX committed May 4, 2021
1 parent 45dcc61 commit 789359c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions Sources/SQLiteCombine/SQLiteCombine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ public extension SQLite {
do {
try subscriber.receive(subscription: Subscription(subscriber, db, sql, values))
} catch {
subscriber.receive(subscription: Subscriptions.empty)
subscriber.receive(completion: .failure(error))
}
}
Expand Down Expand Up @@ -179,8 +180,9 @@ extension SQLite.Publisher {
}

deinit {
// sqlite3_finalize(stmt)
cancel()
if stmt != nil {
cancel()
}
}


Expand All @@ -202,7 +204,6 @@ extension SQLite.Publisher {
}
default:
cancel()
// return
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/SQLiteCombineTests/SQLiteCombineTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ final class SQLiteCombineTests: XCTestCase {
successExpectation.isInverted = true
let valueExpectation = expectation(description: "Receive value")
valueExpectation.isInverted = true
_ = db.publisher(sql: "!")
_ = db.publisher(sql: "CREATE TABLE test (one, two, three, four, five)")
.sink { completion in
if case let .failure(error) = completion {
XCTAssert(error.localizedDescription.contains("DBError error 1"))
Expand Down

0 comments on commit 789359c

Please sign in to comment.