File tree Expand file tree Collapse file tree 4 files changed +38
-15
lines changed
Sources/FluentPostgresDriver
Tests/FluentPostgresDriverTests Expand file tree Collapse file tree 4 files changed +38
-15
lines changed Original file line number Diff line number Diff line change 1- name : Test Matrix
2-
1+ name : test
32on :
43 pull_request :
54 push :
65 branches :
76 - master
8-
9- defaults :
10- run :
11- shell : bash
12-
137jobs :
14-
15- Linux :
8+ linux :
169 runs-on : ubuntu-latest
1710 strategy :
1811 fail-fast : false
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ let package = Package(
1010 . library( name: " FluentPostgresDriver " , targets: [ " FluentPostgresDriver " ] ) ,
1111 ] ,
1212 dependencies: [
13- . package ( url: " https://github.com/vapor/fluent-kit.git " , from: " 1.0.0-rc.2 " ) ,
13+ . package ( url: " https://github.com/vapor/fluent-kit.git " , from: " 1.0.0-rc.2.7 " ) ,
1414 . package ( url: " https://github.com/vapor/postgres-kit.git " , from: " 2.0.0 " ) ,
1515 ] ,
1616 targets: [
Original file line number Diff line number Diff line change @@ -3,28 +3,47 @@ import FluentSQL
33struct PostgresConverterDelegate : SQLConverterDelegate {
44 func customDataType( _ dataType: DatabaseSchema . DataType ) -> SQLExpression ? {
55 switch dataType {
6- case . uint8:
7- return SQLRaw ( #""char""# )
86 case . uuid:
97 return SQLRaw ( " UUID " )
108 case . bool:
119 return SQLRaw ( " BOOL " )
1210 case . data:
1311 return SQLRaw ( " BYTEA " )
12+ case . date:
13+ return SQLRaw ( " DATE " )
1414 case . datetime:
1515 return SQLRaw ( " TIMESTAMPTZ " )
1616 case . double:
1717 return SQLRaw ( " DOUBLE PRECISION " )
18- case . json :
18+ case . dictionary :
1919 return SQLRaw ( " JSONB " )
20+ case . array( of: let type) :
21+ if let type = type, let dataType = self . customDataType ( type) {
22+ return SQLArrayDataType ( dataType: dataType)
23+ } else {
24+ return SQLRaw ( " JSONB " )
25+ }
2026 case . enum( let value) :
2127 return SQLIdentifier ( value. name)
22- default :
28+ case . int8, . uint8:
29+ return SQLRaw ( #""char""# )
30+ case . int16, . uint16:
31+ return SQLRaw ( " SMALLINT " )
32+ case . int32, . uint32:
33+ return SQLRaw ( " INT " )
34+ case . int64, . uint64:
35+ return SQLRaw ( " BIGINT " )
36+ case . string:
37+ return SQLRaw ( " TEXT " )
38+ case . time:
39+ return SQLRaw ( " TIME " )
40+ case . float:
41+ return SQLRaw ( " FLOAT " )
42+ case . custom:
2343 return nil
2444 }
2545 }
2646
27-
2847 func nestedFieldExpression( _ column: String , _ path: [ String ] ) -> SQLExpression {
2948 switch path. count {
3049 case 1 :
@@ -37,3 +56,11 @@ struct PostgresConverterDelegate: SQLConverterDelegate {
3756 }
3857 }
3958}
59+
60+ private struct SQLArrayDataType : SQLExpression {
61+ let dataType : SQLExpression
62+ func serialize( to serializer: inout SQLSerializer ) {
63+ self . dataType. serialize ( to: & serializer)
64+ serializer. write ( " [] " )
65+ }
66+ }
Original file line number Diff line number Diff line change @@ -5,6 +5,8 @@ import XCTest
55
66final class FluentPostgresDriverTests : XCTestCase {
77 func testAll( ) throws { try self . benchmarker. testAll ( ) }
8+
9+ #if Xcode
810 func testAggregate( ) throws { try self . benchmarker. testAggregate ( ) }
911 func testArray( ) throws { try self . benchmarker. testArray ( ) }
1012 func testBatch( ) throws { try self . benchmarker. testBatch ( ) }
@@ -34,6 +36,7 @@ final class FluentPostgresDriverTests: XCTestCase {
3436 func testTimestamp( ) throws { try self . benchmarker. testTimestamp ( ) }
3537 func testTransaction( ) throws { try self . benchmarker. testTransaction ( ) }
3638 func testUnique( ) throws { try self . benchmarker. testUnique ( ) }
39+ #endif
3740
3841 func testDatabaseError( ) throws {
3942 let sql = ( self . db as! SQLDatabase )
You can’t perform that action at this time.
0 commit comments