Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 918cfab

Browse files
add data -> bytea support (vapor#118)
1 parent d5fe3aa commit 918cfab

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

‎Sources/FluentPostgresDriver/PostgresConverterDelegate.swift‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ struct PostgresConverterDelegate: SQLConverterDelegate {
77
return SQLRaw("UUID")
88
case .bool:
99
return SQLRaw("BOOL")
10+
case .data:
11+
return SQLRaw("BYTEA")
1012
default:
1113
return nil
1214
}

‎Tests/FluentPostgresDriverTests/FluentPostgresDriverTests.swift‎

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

115+
func testBlob() throws {
116+
struct Foo: Model {
117+
static let shared = Foo()
118+
var id = Field<Int?>("id")
119+
var data = Field<[UInt8]>("data")
120+
}
121+
122+
struct CreateFoo: Migration {
123+
func prepare(on database: Database) -> EventLoopFuture<Void> {
124+
return database.schema(Foo.self)
125+
.field(\.id, .int, .identifier(auto: true))
126+
.field(\.data, .data, .required)
127+
.create()
128+
}
129+
130+
func revert(on database: Database) -> EventLoopFuture<Void> {
131+
return database.schema(Foo.self).delete()
132+
}
133+
}
134+
135+
try CreateFoo().prepare(on: self.connectionPool).wait()
136+
try CreateFoo().revert(on: self.connectionPool).wait()
137+
}
138+
115139
func testSaveModelWithBool() throws {
116140
struct Organization: Model {
117141
static let shared = Organization()

‎Tests/FluentPostgresDriverTests/XCTestManifests.swift‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ extension FluentPostgresDriverTests {
1111
("testAsyncCreate", testAsyncCreate),
1212
("testBatchCreate", testBatchCreate),
1313
("testBatchUpdate", testBatchUpdate),
14+
("testBlob", testBlob),
1415
("testChunkedFetch", testChunkedFetch),
1516
("testCreate", testCreate),
1617
("testDelete", testDelete),

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /