@@ -8,15 +8,17 @@ class PostgreSQLConnectionTests: XCTestCase {
8
8
}
9
9
10
10
func testBenchmark( ) throws {
11
+ #if !TEST_NO_GENERATED_AS_IDENTITY
11
12
let conn = try PostgreSQLConnection . makeTest ( )
12
13
let benchmarker = SQLBenchmarker ( on: conn)
13
14
try benchmarker. run ( )
15
+ #endif
14
16
}
15
17
16
18
func testVersion( ) throws {
17
19
let client = try PostgreSQLConnection . makeTest ( )
18
20
let results = try client. select ( ) . column ( . function( " version " , [ ] ) ) . all ( decoding: VersionMetadata . self) . wait ( )
19
- XCTAssertTrue ( results [ 0 ] . version. contains ( " 10 ." ) )
21
+ XCTAssertTrue ( results [ 0 ] . version. contains ( " . " ) )
20
22
}
21
23
22
24
func testSelectTypes( ) throws {
@@ -113,10 +115,17 @@ class PostgreSQLConnectionTests: XCTestCase {
113
115
defer {
114
116
_ = try ? client. drop ( table: Foo . self) . ifExists ( ) . run ( ) . wait ( )
115
117
}
118
+ #if TEST_NO_GENERATED_AS_IDENTITY
119
+ try client. create ( table: Foo . self)
120
+ . column ( for: \Foo . id, type: . bigserial, . primaryKey( identifier: nil ) )
121
+ . column ( for: \Foo . dict)
122
+ . run ( ) . wait ( )
123
+ #else
116
124
try client. create ( table: Foo . self)
117
125
. column ( for: \Foo . id, . primaryKey)
118
126
. column ( for: \Foo . dict)
119
127
. run ( ) . wait ( )
128
+ #endif
120
129
121
130
let hello = Hello ( message: " Hello, world! " )
122
131
try client. insert ( into: Foo . self) . value ( Foo ( id: nil , dict: hello) ) . run ( ) . wait ( )
@@ -141,29 +150,45 @@ class PostgreSQLConnectionTests: XCTestCase {
141
150
defer {
142
151
try ? conn. drop ( table: Nulltest . self) . ifExists ( ) . run ( ) . wait ( )
143
152
}
153
+
154
+ #if TEST_NO_GENERATED_AS_IDENTITY
155
+ try conn. create ( table: Nulltest . self)
156
+ . column ( for: \Nulltest . i, type: . bigserial, . primaryKey( default: nil ) )
157
+ . column ( for: \Nulltest . d)
158
+ . run ( ) . wait ( )
159
+ #else
144
160
try conn. create ( table: Nulltest . self)
145
161
. column ( for: \Nulltest . i, . primaryKey)
146
162
. column ( for: \Nulltest . d)
147
163
. run ( ) . wait ( )
164
+ #endif
148
165
149
166
try conn. insert ( into: Nulltest . self) . value ( Nulltest ( i: nil , d: nil ) ) . run ( ) . wait ( )
150
167
}
151
168
152
169
func testGH24( ) throws {
153
170
/// PREPARE
154
171
let client = try PostgreSQLConnection . makeTest ( )
172
+
173
+ let idtype : String
174
+
175
+ #if TEST_NO_GENERATED_AS_IDENTITY
176
+ idtype = " BIGSERIAL "
177
+ #else
178
+ idtype = " BIGINT GENERATED BY DEFAULT AS IDENTITY "
179
+ #endif
155
180
156
181
/// CREATE
157
182
let _ = try client. query ( """
158
183
CREATE TABLE " users " ( " id " UUID PRIMARY KEY, " name " TEXT NOT NULL, " username " TEXT NOT NULL)
159
184
""" ) . wait ( )
160
185
defer { _ = try ! client. simpleQuery ( " DROP TABLE users " ) . wait ( ) }
161
186
let _ = try client. query ( """
162
- CREATE TABLE " acronyms " ( " id " BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, " short " TEXT NOT NULL, " long " TEXT NOT NULL, " userID " UUID NOT NULL, FOREIGN KEY ( " userID " ) REFERENCES " users " ( " id " ), FOREIGN KEY ( " userID " ) REFERENCES " users " ( " id " ))
187
+ CREATE TABLE " acronyms " ( " id " \( idtype ) PRIMARY KEY, " short " TEXT NOT NULL, " long " TEXT NOT NULL, " userID " UUID NOT NULL, FOREIGN KEY ( " userID " ) REFERENCES " users " ( " id " ), FOREIGN KEY ( " userID " ) REFERENCES " users " ( " id " ))
163
188
""" ) . wait ( )
164
189
defer { _ = try ! client. simpleQuery ( " DROP TABLE acronyms " ) . wait ( ) }
165
190
let _ = try client. query ( """
166
- CREATE TABLE " categories " ( " id " BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, " name " TEXT NOT NULL)
191
+ CREATE TABLE " categories " ( " id " \( idtype ) PRIMARY KEY, " name " TEXT NOT NULL)
167
192
""" ) . wait ( )
168
193
defer { _ = try ! client. simpleQuery ( " DROP TABLE categories " ) . wait ( ) }
169
194
let _ = try client. query ( """
@@ -542,7 +567,7 @@ extension PostgreSQLConnection {
542
567
/// Creates a test connection.
543
568
static func makeTest( ) throws -> PostgreSQLConnection {
544
569
let transport : PostgreSQLConnection . TransportConfig
545
- #if TEST_SSL
570
+ #if TEST_USE_UNVERIFIED_TLS
546
571
transport = . unverifiedTLS
547
572
#else
548
573
transport = . cleartext
0 commit comments