Skip to content

Commit 7a7b76e

Browse files
committed
fix file opening + latest updates
1 parent 99dcbe2 commit 7a7b76e

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

Sources/FluentSQLiteDriver/SQLite+Fluent.swift

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,23 @@ private struct SQLiteDialect: SQLDialect {
120120
}
121121

122122
extension SQLiteRow: DatabaseOutput {
123+
public func contains(field: String) -> Bool {
124+
return self.column(field) != nil
125+
}
126+
123127
public func decode<T>(field: String, as type: T.Type) throws -> T where T : Decodable {
124128
return try self.decode(column: field, as: T.self)
125129
}
126130
}
127131

128132
extension SQLiteRow: SQLRow {
133+
public func contains(column: String) -> Bool {
134+
return self.column(column) != nil
135+
}
136+
129137
public func decode<D>(column: String, as type: D.Type) throws -> D where D : Decodable {
130138
guard let data = self.column(column) else {
131-
fatalError()
139+
fatalError("no value found for \(column)")
132140
}
133141
return try SQLiteDataDecoder().decode(D.self, from: data)
134142
}
@@ -183,6 +191,10 @@ private struct LastInsertRow: DatabaseOutput {
183191

184192
let lastAutoincrementID: Int64?
185193

194+
func contains(field: String) -> Bool {
195+
return field == "fluentID"
196+
}
197+
186198
func decode<T>(field: String, as type: T.Type) throws -> T where T : Decodable {
187199
#warning("TODO: fixme, better logic")
188200
switch field {

Sources/FluentSQLiteDriver/SQLiteDataEncoder.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import NIO
12
import Foundation
23

34
public struct SQLiteDataEncoder {

Tests/FluentSQLiteDriverTests/FluentSQLiteDriverTests.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,18 @@ final class FluentSQLiteDriverTests: XCTestCase {
8787
try self.benchmarker.testAsyncCreate()
8888
}
8989

90+
func testSoftDelete() throws {
91+
try self.benchmarker.testSoftDelete()
92+
}
93+
94+
func testTimestampable() throws {
95+
try self.benchmarker.testTimestampable()
96+
}
97+
98+
func testLifecycleHooks() throws {
99+
try self.benchmarker.testLifecycleHooks()
100+
}
101+
90102
var benchmarker: FluentBenchmarker {
91103
return .init(database: self.connectionPool)
92104
}

0 commit comments

Comments
 (0)