Skip to content

Commit

Permalink
Merge pull request #32 from vapor/property-wrapper-2
Browse files Browse the repository at this point in the history
property wrappers
  • Loading branch information
tanner0101 authored Jul 31, 2019
2 parents d6f68b8 + 151575d commit 074b34f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ let package = Package(
.library(name: "FluentSQLiteDriver", targets: ["FluentSQLiteDriver"]),
],
dependencies: [
.package(url: "https://github.com/vapor/fluent-kit.git", from: "1.0.0-alpha"),
.package(url: "https://github.com/vapor/fluent-kit.git", .branch("master")),
.package(url: "https://github.com/vapor/sqlite-kit.git", from: "4.0.0-alpha"),
],
targets: [
Expand Down
11 changes: 8 additions & 3 deletions Sources/FluentSQLiteDriver/SQLiteConnection+Database.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,24 @@ private struct LastInsertRow: DatabaseOutput {

let lastAutoincrementID: Int64?

init(lastAutoincrementID: Int64?) {
self.lastAutoincrementID = lastAutoincrementID
}

func contains(field: String) -> Bool {
return field == "fluentID"
}

func decode<T>(field: String, as type: T.Type) throws -> T where T : Decodable {
switch field {
case "fluentID":
if T.self is Int.Type {
if T.self is Int?.Type || T.self is Int.Type {
return Int(self.lastAutoincrementID!) as! T
} else {
fatalError()
fatalError("cannot decode last autoincrement type: \(T.self)")
}
default: throw FluentError.missingField(name: field)
default:
throw FluentError.missingField(name: field)
}
}
}
Expand Down

0 comments on commit 074b34f

Please sign in to comment.