Skip to content

Commit

Permalink
add data -> bytea support (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
tanner0101 authored Jun 19, 2019
1 parent d5fe3aa commit 918cfab
Show file tree
Hide file tree
Showing 3 changed files with 27 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 @@ -7,6 +7,8 @@ struct PostgresConverterDelegate: SQLConverterDelegate {
return SQLRaw("UUID")
case .bool:
return SQLRaw("BOOL")
case .data:
return SQLRaw("BYTEA")
default:
return nil
}
Expand Down
24 changes: 24 additions & 0 deletions Tests/FluentPostgresDriverTests/FluentPostgresDriverTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<Int?>("id")
var data = Field<[UInt8]>("data")
}

struct CreateFoo: Migration {
func prepare(on database: Database) -> EventLoopFuture<Void> {
return database.schema(Foo.self)
.field(\.id, .int, .identifier(auto: true))
.field(\.data, .data, .required)
.create()
}

func revert(on database: Database) -> EventLoopFuture<Void> {
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()
Expand Down
1 change: 1 addition & 0 deletions Tests/FluentPostgresDriverTests/XCTestManifests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ extension FluentPostgresDriverTests {
("testAsyncCreate", testAsyncCreate),
("testBatchCreate", testBatchCreate),
("testBatchUpdate", testBatchUpdate),
("testBlob", testBlob),
("testChunkedFetch", testChunkedFetch),
("testCreate", testCreate),
("testDelete", testDelete),
Expand Down

0 comments on commit 918cfab

Please sign in to comment.