@@ -36,12 +36,10 @@ import StructuredQueriesTestSupport
36
36
/// - Parameters:
37
37
/// - includeSQL: Whether to snapshot the SQL fragment in addition to the results.
38
38
/// - query: A statement.
39
- /// - database: The database to read from . A value of `nil` will use
39
+ /// - database: The database to use . A value of `nil` will use
40
40
/// `@Dependency(\.defaultDatabase)`.
41
41
/// - sql: A snapshot of the SQL produced by the statement.
42
42
/// - results: A snapshot of the results.
43
- /// to `1` for invoking this helper directly, but if you write a wrapper function that automates
44
- /// the `execute` trailing closure, you should pass `0` instead.
45
43
/// - fileID: The source `#fileID` associated with the assertion.
46
44
/// - filePath: The source `#filePath` associated with the assertion.
47
45
/// - function: The source `#function` associated with the assertion
@@ -52,7 +50,7 @@ import StructuredQueriesTestSupport
52
50
public func assertQuery< each V : QueryRepresentable , S: StructuredQueriesCore . Statement < ( repeat each V ) > > (
53
51
includeSQL: Bool = false ,
54
52
_ query: S ,
55
- database: ( any DatabaseReader ) ? = nil ,
53
+ database: ( any DatabaseWriter ) ? = nil ,
56
54
sql: ( ( ) -> String ) ? = nil ,
57
55
results: ( ( ) -> String ) ? = nil ,
58
56
fileID: StaticString = #fileID,
@@ -80,7 +78,7 @@ public func assertQuery<each V: QueryRepresentable, S: StructuredQueriesCore.Sta
80
78
}
81
79
do {
82
80
@Dependency ( \. defaultDatabase) var defaultDatabase
83
- let rows = try ( database ?? defaultDatabase) . read { try query. fetchAll ( $0) }
81
+ let rows = try ( database ?? defaultDatabase) . write { try query. fetchAll ( $0) }
84
82
var table = " "
85
83
printTable ( rows, to: & table)
86
84
if !table. isEmpty {
@@ -165,11 +163,9 @@ public func assertQuery<each V: QueryRepresentable, S: StructuredQueriesCore.Sta
165
163
/// - includeSQL: Whether to snapshot the SQL fragment in addition to the results.
166
164
/// - query: A statement.
167
165
/// - sql: A snapshot of the SQL produced by the statement.
168
- /// - database: The database to read from . A value of `nil` will use
166
+ /// - database: The database to use . A value of `nil` will use
169
167
/// `@Dependency(\.defaultDatabase)`.
170
168
/// - results: A snapshot of the results.
171
- /// to `1` for invoking this helper directly, but if you write a wrapper function that automates
172
- /// the `execute` trailing closure, you should pass `0` instead.
173
169
/// - fileID: The source `#fileID` associated with the assertion.
174
170
/// - filePath: The source `#filePath` associated with the assertion.
175
171
/// - function: The source `#function` associated with the assertion
@@ -179,7 +175,7 @@ public func assertQuery<each V: QueryRepresentable, S: StructuredQueriesCore.Sta
179
175
public func assertQuery< S: SelectStatement , each J : StructuredQueriesCore . Table > (
180
176
includeSQL: Bool = false ,
181
177
_ query: S ,
182
- database: ( any DatabaseReader ) ? = nil ,
178
+ database: ( any DatabaseWriter ) ? = nil ,
183
179
sql: ( ( ) -> String ) ? = nil ,
184
180
results: ( ( ) -> String ) ? = nil ,
185
181
fileID: StaticString = #fileID,
0 commit comments