@@ -264,6 +264,21 @@ class DatabaseTests: XCTestCase {
264264 XCTAssertEqual ( row, one)
265265 }
266266
267+ func testReturnValueFromInTransactionWithoutTry( ) throws {
268+ let one : SQLiteArguments = [
269+ " id " : . integer( 1 ) , " float " : . double( 1.23 ) , " string " : . text( " 123 " ) , " data " : . data( _textData)
270+ ]
271+
272+ XCTAssertNoThrow ( try database. execute ( raw: _createTableWithFloatStringData) )
273+ XCTAssertNoThrow ( try database. write ( _insertIDFloatStringAndData, arguments: one) )
274+
275+ let row = database. inTransaction { db in
276+ return try ? db. read ( _selectWhereID, arguments: [ " id " : . integer( 1 ) ] ) . first
277+ }
278+
279+ XCTAssertEqual ( row, one)
280+ }
281+
267282 func testInvalidInsertOfBlobInTransactionRollsBack( ) throws {
268283 let one : SQLiteArguments = [ " id " : . integer( 1 ) , " data " : . data( _textData) ]
269284 let two : SQLiteArguments = [ " id " : . integer( 2 ) ]
@@ -321,6 +336,8 @@ class DatabaseTests: XCTestCase {
321336 ( " testInsertAndFetchValidJSON " , testInsertAndFetchValidJSON) ,
322337 ( " testInsertInvalidJSON " , testInsertInvalidJSON) ,
323338 ( " testInsertFloatStringAndDataInTransaction " , testInsertFloatStringAndDataInTransaction) ,
339+ ( " testReturnValueFromInTransaction " , testReturnValueFromInTransaction) ,
340+ ( " testReturnValueFromInTransactionWithoutTry " , testReturnValueFromInTransactionWithoutTry) ,
324341 ( " testInvalidInsertOfBlobInTransactionRollsBack " , testInvalidInsertOfBlobInTransactionRollsBack) ,
325342 ( " testHasOpenTransactions " , testHasOpenTransactions) ,
326343 ]
0 commit comments