diff --git a/Sources/FluentPostgresDriver/PostgresConverterDelegate.swift b/Sources/FluentPostgresDriver/PostgresConverterDelegate.swift index b61c847..b9a096f 100644 --- a/Sources/FluentPostgresDriver/PostgresConverterDelegate.swift +++ b/Sources/FluentPostgresDriver/PostgresConverterDelegate.swift @@ -7,6 +7,8 @@ struct PostgresConverterDelegate: SQLConverterDelegate { return SQLRaw("UUID") case .bool: return SQLRaw("BOOL") + case .data: + return SQLRaw("BYTEA") default: return nil } diff --git a/Tests/FluentPostgresDriverTests/FluentPostgresDriverTests.swift b/Tests/FluentPostgresDriverTests/FluentPostgresDriverTests.swift index 22ec12a..f04cdeb 100644 --- a/Tests/FluentPostgresDriverTests/FluentPostgresDriverTests.swift +++ b/Tests/FluentPostgresDriverTests/FluentPostgresDriverTests.swift @@ -112,6 +112,30 @@ final class FluentPostgresDriverTests: XCTestCase { try self.benchmarker.testUUIDModel() } + func testBlob() throws { + struct Foo: Model { + static let shared = Foo() + var id = Field("id") + var data = Field<[UInt8]>("data") + } + + struct CreateFoo: Migration { + func prepare(on database: Database) -> EventLoopFuture { + return database.schema(Foo.self) + .field(\.id, .int, .identifier(auto: true)) + .field(\.data, .data, .required) + .create() + } + + func revert(on database: Database) -> EventLoopFuture { + return database.schema(Foo.self).delete() + } + } + + try CreateFoo().prepare(on: self.connectionPool).wait() + try CreateFoo().revert(on: self.connectionPool).wait() + } + func testSaveModelWithBool() throws { struct Organization: Model { static let shared = Organization() diff --git a/Tests/FluentPostgresDriverTests/XCTestManifests.swift b/Tests/FluentPostgresDriverTests/XCTestManifests.swift index dc6ef62..afddf85 100644 --- a/Tests/FluentPostgresDriverTests/XCTestManifests.swift +++ b/Tests/FluentPostgresDriverTests/XCTestManifests.swift @@ -11,6 +11,7 @@ extension FluentPostgresDriverTests { ("testAsyncCreate", testAsyncCreate), ("testBatchCreate", testBatchCreate), ("testBatchUpdate", testBatchUpdate), + ("testBlob", testBlob), ("testChunkedFetch", testChunkedFetch), ("testCreate", testCreate), ("testDelete", testDelete),