Skip to content

Commit 6d44b50

Browse files
committed
dbkit gm 1.0.0 test fixes
1 parent 5bdefc2 commit 6d44b50

File tree

4 files changed

+6
-18
lines changed

4 files changed

+6
-18
lines changed

Sources/FluentPostgreSQL/PostgreSQLDatabase+QuerySupporting.swift

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Core
33
import FluentSQL
44

55
/// Adds ability to do basic Fluent queries using a `PostgreSQLDatabase`.
6-
extension PostgreSQLDatabase: QuerySupporting, CustomSQLSupporting {
6+
extension PostgreSQLDatabase: QuerySupporting, CustomSQLSupporting, KeyedCacheSupporting {
77
/// See `QuerySupporting.execute`
88
public static func execute(
99
query: DatabaseQuery<PostgreSQLDatabase>,
@@ -32,6 +32,7 @@ extension PostgreSQLDatabase: QuerySupporting, CustomSQLSupporting {
3232
return .init(column: col, value: .placeholder)
3333
}
3434
parameters = modelData + bindValues
35+
sqlQuery = .manipulation(m)
3536
case .query: parameters = bindValues
3637
case .definition: parameters = []
3738
}
@@ -45,11 +46,6 @@ extension PostgreSQLDatabase: QuerySupporting, CustomSQLSupporting {
4546
let sqlSerializer = PostgreSQLSQLSerializer()
4647
let sqlString = sqlSerializer.serialize(sqlQuery)
4748

48-
/// Log supporting
49-
if let logger = connection.logger {
50-
logger.log(query: sqlString, parameters: parameters)
51-
}
52-
5349
// Run the query
5450
return connection.query(sqlString, parameters) { row in
5551
var res: [QueryField: PostgreSQLData] = [:]

Sources/FluentPostgreSQL/PostgreSQLDatabase+SchemaSupporting.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,6 @@ extension PostgreSQLDatabase: SchemaSupporting, IndexSupporting {
7777
}
7878

7979
let sqlString = PostgreSQLSQLSerializer().serialize(sqlQuery)
80-
if let logger = connection.logger {
81-
logger.log(query: sqlString, parameters: [])
82-
}
8380
return connection.query(sqlString).map(to: Void.self) { rows in
8481
assert(rows.count == 0)
8582
}.flatMap(to: Void.self) {

Sources/FluentPostgreSQL/PostgreSQLSQLSerializer.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ internal class PostgreSQLSQLSerializer: SQLSerializer {
1010
self.placeholderOffset = 1
1111
}
1212

13-
/// See `SQLSerializer.makeEscapedString(from:)`
13+
/// See `SQLSerializer`
1414
func makeEscapedString(from string: String) -> String {
1515
return "\"\(string)\""
1616
}
1717

18-
/// See `SQLSerializer.makePlaceholder(name:)`
19-
func makePlaceholder(name: String) -> String {
18+
/// See `SQLSerializer`
19+
func makePlaceholder() -> String {
2020
defer { placeholderOffset += 1 }
2121
return "$\(placeholderOffset)"
2222
}

Tests/FluentPostgreSQLTests/FluentPostgreSQLTests.swift

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class FluentPostgreSQLTests: XCTestCase {
2727
)
2828
database = PostgreSQLDatabase(config: config)
2929
let eventLoop = MultiThreadedEventLoopGroup(numThreads: 1)
30-
benchmarker = Benchmarker(database, on: eventLoop, onFail: XCTFail)
30+
benchmarker = try! Benchmarker(database, on: eventLoop, onFail: XCTFail)
3131
}
3232

3333
func testSchema() throws {
@@ -136,7 +136,6 @@ class FluentPostgreSQLTests: XCTestCase {
136136

137137

138138
func testUpdate() throws {
139-
benchmarker.database.enableLogging(using: .print)
140139
let conn = try benchmarker.pool.requestConnection().wait()
141140
defer { try? User.revert(on: conn).wait() }
142141
try User.prepare(on: conn).wait()
@@ -148,7 +147,6 @@ class FluentPostgreSQLTests: XCTestCase {
148147
}
149148

150149
func testGH24() throws {
151-
benchmarker.database.enableLogging(using: .print)
152150
let conn = try benchmarker.pool.requestConnection().wait()
153151
defer { try? Allergy.revert(on: conn).wait() }
154152
try Allergy.prepare(on: conn).wait()
@@ -179,7 +177,6 @@ class FluentPostgreSQLTests: XCTestCase {
179177
try print(Pet.reflectProperties())
180178

181179
/// - prepare db
182-
benchmarker.database.enableLogging(using: .print)
183180
let conn = try benchmarker.pool.requestConnection().wait()
184181
defer { try? Pet.revert(on: conn).wait() }
185182
try Pet.prepare(on: conn).wait()
@@ -196,7 +193,6 @@ class FluentPostgreSQLTests: XCTestCase {
196193
}
197194

198195
func testPersistsDateMillisecondPart() throws {
199-
database.enableLogging(using: DatabaseLogger(handler: { print($0) }))
200196
let conn = try benchmarker.pool.requestConnection().wait()
201197
defer { try? DefaultTest.revert(on: conn).wait() }
202198
try DefaultTest.prepare(on: conn).wait()
@@ -220,7 +216,6 @@ class FluentPostgreSQLTests: XCTestCase {
220216
}
221217

222218
/// - prepare db
223-
benchmarker.database.enableLogging(using: .print)
224219
let conn = try benchmarker.pool.requestConnection().wait()
225220
defer { try? Foo.revert(on: conn).wait() }
226221
try Foo.prepare(on: conn).wait()

0 commit comments

Comments
 (0)