Skip to content

Commit

Permalink
support BOOL type in migration (#117)
Browse files Browse the repository at this point in the history
  • Loading branch information
tanner0101 authored Jun 13, 2019
1 parent 5959f23 commit d5fe3aa
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Sources/FluentPostgresDriver/PostgresConverterDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ struct PostgresConverterDelegate: SQLConverterDelegate {
switch dataType {
case .uuid:
return SQLRaw("UUID")
case .bool:
return SQLRaw("BOOL")
default:
return nil
}
Expand Down
18 changes: 18 additions & 0 deletions Tests/FluentPostgresDriverTests/FluentPostgresDriverTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,24 @@ final class FluentPostgresDriverTests: XCTestCase {
try self.benchmarker.testUUIDModel()
}

func testSaveModelWithBool() throws {
struct Organization: Model {
static let shared = Organization()
static let entity = "organizations"
let id = Field<Int?>("id")
let disabled = Field<Bool>("disabled")
}

try Organization.autoMigration().prepare(on: self.connectionPool).wait()
defer {
try! Organization.autoMigration().revert(on: self.connectionPool).wait()
}

let new = Organization.row()
new.disabled = false
try new.save(on: self.connectionPool).wait()
}

var benchmarker: FluentBenchmarker!
var connectionPool: ConnectionPool<PostgresConnectionSource>!
var eventLoopGroup: EventLoopGroup!
Expand Down
2 changes: 2 additions & 0 deletions Tests/FluentPostgresDriverTests/XCTestManifests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ extension FluentPostgresDriverTests {
("testNestedModel", testNestedModel),
("testNullifyField", testNullifyField),
("testRead", testRead),
("testSaveModelWithBool", testSaveModelWithBool),
("testSoftDelete", testSoftDelete),
("testSort", testSort),
("testTimestampable", testTimestampable),
("testUniqueFields", testUniqueFields),
("testUpdate", testUpdate),
("testUUIDModel", testUUIDModel),
]
}

Expand Down

0 comments on commit d5fe3aa

Please sign in to comment.