@@ -102,24 +102,25 @@ struct FluentPostgresDriverTests {
102102 init ( ) {
103103 #expect( isLoggingConfigured)
104104 }
105-
105+
106+ #if !compiler(<6.1) // #expect(throws:) doesn't return the Error until 6.1
106107 @Test
107108 func databaseError( ) async throws {
108109 try await withDbs { dbs, db in
109110 let sql1 = ( db as! any SQLDatabase )
110- let error = await #expect( throws: ( any Error ) . self) { try await sql1. raw ( " asdf " ) . run ( ) }
111- #expect( ( error as? any DatabaseError ) ? . isSyntaxError ?? false , " \( String ( reflecting: error ) ) " )
112- #expect( !( ( error as? any DatabaseError ) ? . isConstraintFailure ?? true ) , " \( String ( reflecting: error ) ) " )
113- #expect( !( ( error as? any DatabaseError ) ? . isConnectionClosed ?? true ) , " \( String ( reflecting: error ) ) " )
111+ let error1 = await #expect( throws: ( any Error ) . self) { try await sql1. raw ( " asdf " ) . run ( ) }
112+ #expect( ( error1 as? any DatabaseError ) ? . isSyntaxError ?? false , " \( String ( reflecting: error1 ) ) " )
113+ #expect( !( ( error1 as? any DatabaseError ) ? . isConstraintFailure ?? true ) , " \( String ( reflecting: error1 ) ) " )
114+ #expect( !( ( error1 as? any DatabaseError ) ? . isConnectionClosed ?? true ) , " \( String ( reflecting: error1 ) ) " )
114115
115116 let sql2 = ( dbs. database ( . a, logger: . init( label: " test.fluent.a " ) , on: dbs. eventLoopGroup. any ( ) ) !) as! any SQLDatabase
116117 try await sql2. drop ( table: " foo " ) . ifExists ( ) . run ( )
117118 try await sql2. create ( table: " foo " ) . column ( " name " , type: . text, . unique) . run ( )
118119 try await sql2. insert ( into: " foo " ) . columns ( " name " ) . values ( " bar " ) . run ( )
119- await #expect( throws: ( any Error ) . self) { try await sql2. insert ( into: " foo " ) . columns ( " name " ) . values ( " bar " ) . run ( ) }
120- #expect( ( error as? any DatabaseError ) ? . isSyntaxError ?? false , " \( String ( reflecting: error ) ) " )
121- #expect( !( ( error as? any DatabaseError ) ? . isConstraintFailure ?? true ) , " \( String ( reflecting: error ) ) " )
122- #expect( !( ( error as? any DatabaseError ) ? . isConnectionClosed ?? true ) , " \( String ( reflecting: error ) ) " )
120+ let error2 = await #expect( throws: ( any Error ) . self) { try await sql2. insert ( into: " foo " ) . columns ( " name " ) . values ( " bar " ) . run ( ) }
121+ #expect( ( error2 as? any DatabaseError ) ? . isSyntaxError ?? false , " \( String ( reflecting: error2 ) ) " )
122+ #expect( !( ( error2 as? any DatabaseError ) ? . isConstraintFailure ?? true ) , " \( String ( reflecting: error2 ) ) " )
123+ #expect( !( ( error2 as? any DatabaseError ) ? . isConnectionClosed ?? true ) , " \( String ( reflecting: error2 ) ) " )
123124 }
124125
125126 // Disabled until we figure out why it hangs instead of throwing an error.
@@ -134,6 +135,7 @@ struct FluentPostgresDriverTests {
134135 // XCTAssertFalse(($0 as? any DatabaseError)?.isConstraintFailure ?? true, "\(String(reflecting: $0))")
135136 //}
136137 }
138+ #endif
137139
138140 @Test
139141 func blob( ) async throws {
0 commit comments