File tree 4 files changed +38
-15
lines changed
Sources/FluentPostgresDriver
Tests/FluentPostgresDriverTests
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
3
2
on :
4
3
pull_request :
5
4
push :
6
5
branches :
7
6
- master
8
-
9
- defaults :
10
- run :
11
- shell : bash
12
-
13
7
jobs :
14
-
15
- Linux :
8
+ linux :
16
9
runs-on : ubuntu-latest
17
10
strategy :
18
11
fail-fast : false
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ let package = Package(
10
10
. library( name: " FluentPostgresDriver " , targets: [ " FluentPostgresDriver " ] ) ,
11
11
] ,
12
12
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 " ) ,
14
14
. package ( url: " https://github.com/vapor/postgres-kit.git " , from: " 2.0.0 " ) ,
15
15
] ,
16
16
targets: [
Original file line number Diff line number Diff line change @@ -3,28 +3,47 @@ import FluentSQL
3
3
struct PostgresConverterDelegate : SQLConverterDelegate {
4
4
func customDataType( _ dataType: DatabaseSchema . DataType ) -> SQLExpression ? {
5
5
switch dataType {
6
- case . uint8:
7
- return SQLRaw ( #""char""# )
8
6
case . uuid:
9
7
return SQLRaw ( " UUID " )
10
8
case . bool:
11
9
return SQLRaw ( " BOOL " )
12
10
case . data:
13
11
return SQLRaw ( " BYTEA " )
12
+ case . date:
13
+ return SQLRaw ( " DATE " )
14
14
case . datetime:
15
15
return SQLRaw ( " TIMESTAMPTZ " )
16
16
case . double:
17
17
return SQLRaw ( " DOUBLE PRECISION " )
18
- case . json :
18
+ case . dictionary :
19
19
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
+ }
20
26
case . enum( let value) :
21
27
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:
23
43
return nil
24
44
}
25
45
}
26
46
27
-
28
47
func nestedFieldExpression( _ column: String , _ path: [ String ] ) -> SQLExpression {
29
48
switch path. count {
30
49
case 1 :
@@ -37,3 +56,11 @@ struct PostgresConverterDelegate: SQLConverterDelegate {
37
56
}
38
57
}
39
58
}
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
5
5
6
6
final class FluentPostgresDriverTests : XCTestCase {
7
7
func testAll( ) throws { try self . benchmarker. testAll ( ) }
8
+
9
+ #if Xcode
8
10
func testAggregate( ) throws { try self . benchmarker. testAggregate ( ) }
9
11
func testArray( ) throws { try self . benchmarker. testArray ( ) }
10
12
func testBatch( ) throws { try self . benchmarker. testBatch ( ) }
@@ -34,6 +36,7 @@ final class FluentPostgresDriverTests: XCTestCase {
34
36
func testTimestamp( ) throws { try self . benchmarker. testTimestamp ( ) }
35
37
func testTransaction( ) throws { try self . benchmarker. testTransaction ( ) }
36
38
func testUnique( ) throws { try self . benchmarker. testUnique ( ) }
39
+ #endif
37
40
38
41
func testDatabaseError( ) throws {
39
42
let sql = ( self . db as! SQLDatabase )
You can’t perform that action at this time.
0 commit comments