Skip to content

support BOOL type in migration #117

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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