@@ -379,6 +379,33 @@ class FluentPostgreSQLTests: XCTestCase {
379
379
XCTAssertEqual ( c? . name, " Earth " )
380
380
}
381
381
382
+ func testEnumArray( ) throws {
383
+ enum A : Int16 , Codable , CaseIterable , ReflectionDecodable {
384
+ static var allCases : [ A ] = [ . a, . b, . c]
385
+ case a, b, c
386
+ }
387
+ struct B : PostgreSQLModel , PostgreSQLMigration {
388
+ var id : Int ?
389
+ var a : [ A ]
390
+
391
+ static func prepare( on conn: PostgreSQLConnection ) -> Future < Void > {
392
+ return PostgreSQLDatabase . create ( B . self, on: conn) { builder in
393
+ builder. field ( for: \. id, isIdentifier: true )
394
+ builder. field ( for: \. a, type: . array( . int2) , . notNull)
395
+ }
396
+ }
397
+ }
398
+
399
+ let conn = try benchmarker. pool. requestConnection ( ) . wait ( )
400
+ conn. logger = DatabaseLogger ( database: . psql, handler: PrintLogHandler ( ) )
401
+ defer { benchmarker. pool. releaseConnection ( conn) }
402
+ defer { try ? B . revert ( on: conn) . wait ( ) }
403
+ try B . prepare ( on: conn) . wait ( )
404
+
405
+ let b = try B ( id: nil , a: [ . a, . b, . c] ) . save ( on: conn) . wait ( )
406
+ XCTAssertEqual ( b. id, 1 )
407
+ }
408
+
382
409
static let allTests = [
383
410
( " testBenchmark " , testBenchmark) ,
384
411
( " testNestedStruct " , testNestedStruct) ,
@@ -394,6 +421,7 @@ class FluentPostgreSQLTests: XCTestCase {
394
421
( " testSort " , testSort) ,
395
422
( " testCustomFilter " , testCustomFilter) ,
396
423
( " testCreateOrUpdate " , testCreateOrUpdate) ,
424
+ ( " testEnumArray " , testEnumArray) ,
397
425
]
398
426
}
399
427
0 commit comments