Skip to content

Commit d5fe3aa

Browse files
authored
support BOOL type in migration (#117)
1 parent 5959f23 commit d5fe3aa

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

Sources/FluentPostgresDriver/PostgresConverterDelegate.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ struct PostgresConverterDelegate: SQLConverterDelegate {
55
switch dataType {
66
case .uuid:
77
return SQLRaw("UUID")
8+
case .bool:
9+
return SQLRaw("BOOL")
810
default:
911
return nil
1012
}

Tests/FluentPostgresDriverTests/FluentPostgresDriverTests.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,24 @@ final class FluentPostgresDriverTests: XCTestCase {
112112
try self.benchmarker.testUUIDModel()
113113
}
114114

115+
func testSaveModelWithBool() throws {
116+
struct Organization: Model {
117+
static let shared = Organization()
118+
static let entity = "organizations"
119+
let id = Field<Int?>("id")
120+
let disabled = Field<Bool>("disabled")
121+
}
122+
123+
try Organization.autoMigration().prepare(on: self.connectionPool).wait()
124+
defer {
125+
try! Organization.autoMigration().revert(on: self.connectionPool).wait()
126+
}
127+
128+
let new = Organization.row()
129+
new.disabled = false
130+
try new.save(on: self.connectionPool).wait()
131+
}
132+
115133
var benchmarker: FluentBenchmarker!
116134
var connectionPool: ConnectionPool<PostgresConnectionSource>!
117135
var eventLoopGroup: EventLoopGroup!

Tests/FluentPostgresDriverTests/XCTestManifests.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@ extension FluentPostgresDriverTests {
2727
("testNestedModel", testNestedModel),
2828
("testNullifyField", testNullifyField),
2929
("testRead", testRead),
30+
("testSaveModelWithBool", testSaveModelWithBool),
3031
("testSoftDelete", testSoftDelete),
3132
("testSort", testSort),
3233
("testTimestampable", testTimestampable),
3334
("testUniqueFields", testUniqueFields),
3435
("testUpdate", testUpdate),
36+
("testUUIDModel", testUUIDModel),
3537
]
3638
}
3739

0 commit comments

Comments
 (0)