@@ -203,7 +203,7 @@ protocol QueriesQueries: ConnectionWrapper {
203203
204204struct QueriesQueriesNoop: QueriesQueries {
205205 let connection: any Connection = NoopConnection()
206- let insertUser: AnyQuery<InsertUserInput, () >
206+ let insertUser: AnyQuery<InsertUserInput, Int >
207207 let selectUsers: AnyQuery<(), [User]>
208208 let selectUserById: AnyQuery<Int, User?>
209209 let selectUserByIds: AnyQuery<[Int], [User]>
@@ -213,7 +213,7 @@ struct QueriesQueriesNoop: QueriesQueries {
213213 let selectWithOptionalInterest: AnyQuery<(), [SelectWithOptionalInterestOutput]>
214214
215215 init(
216- insertUser: any InsertUserQuery = Queries.Just(),
216+ insertUser: any InsertUserQuery = Queries.Just(0 ),
217217 selectUsers: any SelectUsersQuery = Queries.Just(),
218218 selectUserById: any SelectUserByIdQuery = Queries.Just(),
219219 selectUserByIds: any SelectUserByIdsQuery = Queries.Just(),
@@ -236,15 +236,15 @@ struct QueriesQueriesNoop: QueriesQueries {
236236struct QueriesQueriesImpl: QueriesQueries {
237237 let connection: any Connection
238238
239- var insertUser: DatabaseQuery<InsertUserInput, () > {
240- DatabaseQuery<InsertUserInput, () >(
239+ var insertUser: DatabaseQuery<InsertUserInput, Int > {
240+ DatabaseQuery<InsertUserInput, Int >(
241241 .write,
242242 in: connection,
243243 watchingTables: ["user"]
244244 ) { input, tx in
245245 let statement = try Otter.Statement(
246246 """
247- INSERT INTO user VALUES (?, ?, ?, ?, ?, ?, ?)
247+ INSERT INTO user VALUES (?, ?, ?, ?, ?, ?, ?) RETURNING id
248248 """,
249249 transaction: tx
250250 )
@@ -255,7 +255,7 @@ struct QueriesQueriesImpl: QueriesQueries {
255255 try statement.bind(value: input.favoriteNumber, to: 5)
256256 try statement.bind(value: input.randomValue, to: 6)
257257 try statement.bind(value: input.bornOn, to: 7, using: CustomDateDatabaseValueAdapter.self, as: String.self)
258- _ = try statement.step ()
258+ return try statement.fetchOne ()
259259 }
260260 }
261261
@@ -410,13 +410,13 @@ struct DB: Database{
410410 }
411411}
412412
413- typealias InsertUserQuery = Query<InsertUserInput, () >
413+ typealias InsertUserQuery = Query<InsertUserInput, Int >
414414extension Query where Input == InsertUserInput {
415415 func execute(id: Int, firstName: String, lastName: String, preference: Bool?, favoriteNumber: Int?, randomValue: SQLAny?, bornOn: Date?) async throws -> Output {
416416 try await execute(with: InsertUserInput(id: id, firstName: firstName, lastName: lastName, preference: preference, favoriteNumber: favoriteNumber, randomValue: randomValue, bornOn: bornOn))
417417 }
418418
419- func execute(id: Int, firstName: String, lastName: String, preference: Bool?, favoriteNumber: Int?, randomValue: SQLAny?, bornOn: Date?, tx: borrowing Transaction) async throws -> Output {
419+ func execute(id: Int, firstName: String, lastName: String, preference: Bool?, favoriteNumber: Int?, randomValue: SQLAny?, bornOn: Date?, tx: borrowing Transaction) throws -> Output {
420420 try execute(with: InsertUserInput(id: id, firstName: firstName, lastName: lastName, preference: preference, favoriteNumber: favoriteNumber, randomValue: randomValue, bornOn: bornOn), tx: tx)
421421 }
422422
@@ -435,7 +435,7 @@ extension Query where Input == SelectUserWithManyInputsInput {
435435 try await execute(with: SelectUserWithManyInputsInput(id: id, firstName: firstName))
436436 }
437437
438- func execute(id: Int, firstName: String, tx: borrowing Transaction) async throws -> Output {
438+ func execute(id: Int, firstName: String, tx: borrowing Transaction) throws -> Output {
439439 try execute(with: SelectUserWithManyInputsInput(id: id, firstName: firstName), tx: tx)
440440 }
441441
0 commit comments