@@ -8,7 +8,7 @@ class PostgreSQLConnectionTests: XCTestCase {
8
8
9
9
func testVersion( ) throws {
10
10
let client = try PostgreSQLConnection . makeTest ( transport: . cleartext)
11
- let results = try client. simpleQuery ( . select ( . version) , decoding : VersionMetadata . self ) . wait ( )
11
+ let results = try client. select ( VersionMetadata . self ) . keys ( . version) . all ( ) . wait ( )
12
12
XCTAssertTrue ( results [ 0 ] . version. contains ( " 10. " ) )
13
13
}
14
14
@@ -84,22 +84,22 @@ class PostgreSQLConnectionTests: XCTestCase {
84
84
let client = try PostgreSQLConnection . makeTest ( transport: . cleartext)
85
85
do {
86
86
// simple query
87
- let results = try client. simpleQuery ( . select( [ . all] , from: " pg_type " ) , decoding: PGType . self) . wait ( )
87
+ let results = try client. simpleQuery ( . select( . all, from: [ " pg_type " ] ) , decoding: PGType . self) . wait ( )
88
88
XCTAssert ( results. count >= 350 , " Results count not large enough: \( results. count) " )
89
89
}
90
90
do {
91
91
// query: default
92
- let results = try client. query ( . select( [ . all ] , from: " pg_type " ) , decoding : PGType . self ) . wait ( )
92
+ let results = try client. select ( PGType . self ) . from ( " pg_type " ) . all ( ) . wait ( )
93
93
XCTAssert ( results. count >= 350 , " Results count not large enough: \( results. count) " )
94
94
}
95
95
do {
96
96
// query: binary
97
- let results = try client. query ( . select( [ . all] , from: " pg_type " ) , resultFormat: . binary, decoding: PGType . self) . wait ( )
97
+ let results = try client. query ( . select( . all, from: [ " pg_type " ] ) , resultFormat: . binary, decoding: PGType . self) . wait ( )
98
98
XCTAssert ( results. count >= 350 , " Results count not large enough: \( results. count) " )
99
99
}
100
100
do {
101
101
// query: text
102
- let results = try client. query ( . select( [ . all] , from: " pg_type " ) , resultFormat: . text, decoding: PGType . self) . wait ( )
102
+ let results = try client. query ( . select( . all, from: [ " pg_type " ] ) , resultFormat: . text, decoding: PGType . self) . wait ( )
103
103
XCTAssert ( results. count >= 350 , " Results count not large enough: \( results. count) " )
104
104
}
105
105
}
@@ -122,7 +122,7 @@ class PostgreSQLConnectionTests: XCTestCase {
122
122
let hello = Hello ( message: " Hello, world! " )
123
123
_ = try client. query ( . insert( into: " foo " , values: [ " id " : . bind( 1 ) , " dict " : . bind( hello) ] ) ) . wait ( )
124
124
125
- let fetch = try client. query ( . select( [ . all ] , from: " foo " ) , decoding : Foo . self ) . wait ( )
125
+ let fetch = try client. select ( Foo . self ) . from ( " foo " ) . all ( ) . wait ( )
126
126
switch fetch. count {
127
127
case 1 :
128
128
XCTAssertEqual ( fetch [ 0 ] . id, 1 )
@@ -335,7 +335,7 @@ class PostgreSQLConnectionTests: XCTestCase {
335
335
_ = try conn. query ( . insert( into: " types " , values:
336
336
PostgreSQLQueryEncoder ( ) . encode ( typesA)
337
337
) ) . wait ( )
338
- let rows = try conn. query ( . select( [ . all] , from: " types " ) ) . wait ( )
338
+ let rows = try conn. query ( . select( . all, from: [ " types " ] ) ) . wait ( )
339
339
switch rows. count {
340
340
case 1 :
341
341
let typesB = try PostgreSQLRowDecoder ( ) . decode ( Types . self, from: rows [ 0 ] )
@@ -370,12 +370,14 @@ class PostgreSQLConnectionTests: XCTestCase {
370
370
let save = try conn. query ( . insert( into: " users " , values: [ " name " : . bind( " vapor " ) ] ) ) . wait ( )
371
371
XCTAssertEqual ( save. count, 0 )
372
372
373
- let search = try conn. query ( . select( [ . all] , from: " users "
374
- // , predicates: [.predicate("name", .equal, .bind("vapor"))]
373
+ let search = try conn. query ( . select(
374
+ . all,
375
+ from: [ " users " ] ,
376
+ predicate: . predicate( " name " , . equal, . bind( " vapor " ) )
375
377
) ) . wait ( )
376
378
XCTAssertEqual ( search. count, 1 )
377
379
378
- try conn. query ( . select( [ " id " , " name " ] , from: " users " ) ) { row in
380
+ try conn. query ( . select( " id " , " name " , from: [ " users " ] ) ) { row in
379
381
print ( row)
380
382
} . wait ( )
381
383
}
@@ -399,12 +401,14 @@ class PostgreSQLConnectionTests: XCTestCase {
399
401
] , returning: " id " ) ) . wait ( )
400
402
XCTAssertEqual ( save. count, 1 )
401
403
402
- let search = try conn. query ( . select( [ . all] , from: " users "
403
- //, where: [.predicate("name", .equal, .bind("vapor"))]
404
+ let search = try conn. query ( . select(
405
+ . all,
406
+ from: [ " users " ] ,
407
+ predicate: . predicate( " name " , . equal, . bind( " vapor " ) )
404
408
) ) . wait ( )
405
409
XCTAssertEqual ( search. count, 1 )
406
410
407
- try conn. query ( . select( [ " id " , " name " , " pet " ] , from: " users " ) ) { row in
411
+ try conn. query ( . select( " id " , " name " , " pet " , from: [ " users " ] ) ) { row in
408
412
print ( row)
409
413
} . wait ( )
410
414
}
@@ -424,7 +428,7 @@ class PostgreSQLConnectionTests: XCTestCase {
424
428
PostgreSQLQueryEncoder ( ) . encode ( time)
425
429
) ) . wait ( )
426
430
427
- let fetch = try conn. query ( . select( [ . all ] , from: " timetest " ) , decoding : Time . self ) . wait ( )
431
+ let fetch : [ Time ] = try conn. select ( Time . self ) . from ( " timetest " ) . all ( ) . wait ( )
428
432
switch fetch. count {
429
433
case 1 :
430
434
XCTAssertEqual ( fetch [ 0 ] , time)
@@ -451,7 +455,7 @@ class PostgreSQLConnectionTests: XCTestCase {
451
455
struct Sum : Decodable {
452
456
var sum : Double
453
457
}
454
- let rows = try conn. query ( . select ( . function( " SUM " , 3.14 , as: " sum " ) ) , decoding : Sum . self ) . wait ( )
458
+ let rows : [ Sum ] = try conn. select ( Sum . self ) . keys ( . function( " SUM " , [ 3.14 ] , as: " sum " ) ) . all ( ) . wait ( )
455
459
switch rows. count {
456
460
case 1 : XCTAssertEqual ( rows [ 0 ] . sum, 3.14 )
457
461
default : XCTFail ( " invalid row count " )
0 commit comments