11import OrderedCollections
22public import SQLKit
3- import protocol NIOCore. EventLoop
4- import class NIOCore. EventLoopFuture
5- import class NIOEmbedded. NIOAsyncTestingEventLoop
63import Logging
7- #if canImport(Dispatch)
8- import class Dispatch. DispatchQueue
9- #endif
104
115extension SQLQueryBuilder {
126 /// Serialize this builder's query and return the textual SQL, discarding any bindings.
@@ -28,23 +22,11 @@ extension SQLQueryBuilder {
2822/// its internal arrays of accumulated "results". Most things about its dialect are mutable.
2923final class TestDatabase : SQLDatabase , @unchecked Sendable {
3024 let logger : Logger = { var l = Logger ( label: " codes.vapor.sql.test " ) ; l. logLevel = . debug; return l } ( )
31- let eventLoop : any EventLoop = NIOAsyncTestingEventLoop ( )
3225 var results : [ String ] = [ ]
3326 var bindResults : [ [ any Encodable & Sendable ] ] = [ ]
3427 var outputs : [ any SQLRow ] = [ ]
3528 var dialect : any SQLDialect { self . _dialect }
3629 var _dialect : GenericDialect = . init( )
37-
38- func execute( sql query: any SQLExpression , _ onRow: @escaping ( any SQLRow ) -> ( ) ) -> EventLoopFuture < Void > {
39- let ( sql, binds) = self . serialize ( query)
40-
41- self . results. append ( sql)
42- self . bindResults. append ( binds)
43- while let row = self . outputs. popLast ( ) {
44- onRow ( row)
45- }
46- return self . eventLoop. makeSucceededFuture ( ( ) )
47- }
4830
4931 func execute( sql query: any SQLExpression , _ onRow: @escaping ( any SQLRow ) -> ( ) ) async throws {
5032 let ( sql, binds) = self . serialize ( query)
@@ -145,11 +127,3 @@ extension SQLKit.SQLDataType: Swift.Equatable {
145127 }
146128 }
147129}
148-
149- /// Used when testing defaulted async implementations
150- struct TestNoAsyncDatabase : SQLDatabase {
151- func execute( sql query: any SQLExpression , _ onRow: @escaping @Sendable ( any SQLRow ) -> ( ) ) -> EventLoopFuture < Void > { self . eventLoop. makeSucceededVoidFuture ( ) }
152- var logger : Logger { . init( label: " l " ) }
153- var eventLoop : any EventLoop { NIOAsyncTestingEventLoop ( ) }
154- var dialect : any SQLDialect { GenericDialect ( ) }
155- }
0 commit comments