@@ -214,6 +214,11 @@ struct SelectWithManyInputsInput: Hashable, Sendable {
214214 let textNotNull: String
215215}
216216
217+ struct InputContainsArrayInput: Hashable, Sendable {
218+ let intPks: [Int]
219+ let barNotNullText: String
220+ }
221+
217222struct QueriesQueries: ConnectionWrapper, Sendable {
218223 let connection: any Connection
219224 var insertFooReturningFoo: any InsertFooReturningFooQuery
@@ -223,6 +228,8 @@ struct QueriesQueries: ConnectionWrapper, Sendable {
223228 var hasEmbeddedFoo: any HasEmbeddedFooQuery
224229 var bothColumnsShouldNotBeNullable: any BothColumnsShouldNotBeNullableQuery
225230 var selectWithManyInputs: any SelectWithManyInputsQuery
231+ var inputIsArray: any InputIsArrayQuery
232+ var inputContainsArray: any InputContainsArrayQuery
226233
227234 static func noop(
228235 insertFooReturningFoo: any InsertFooReturningFooQuery = Queries.Fail(),
@@ -231,7 +238,9 @@ struct QueriesQueries: ConnectionWrapper, Sendable {
231238 selectSingleFoo: any SelectSingleFooQuery = Queries.Just(),
232239 hasEmbeddedFoo: any HasEmbeddedFooQuery = Queries.Just(),
233240 bothColumnsShouldNotBeNullable: any BothColumnsShouldNotBeNullableQuery = Queries.Just(),
234- selectWithManyInputs: any SelectWithManyInputsQuery = Queries.Just()
241+ selectWithManyInputs: any SelectWithManyInputsQuery = Queries.Just(),
242+ inputIsArray: any InputIsArrayQuery = Queries.Just(),
243+ inputContainsArray: any InputContainsArrayQuery = Queries.Just()
235244 ) -> QueriesQueries {
236245 QueriesQueries(
237246 connection: NoopConnection(),
@@ -241,7 +250,9 @@ struct QueriesQueries: ConnectionWrapper, Sendable {
241250 selectSingleFoo: selectSingleFoo,
242251 hasEmbeddedFoo: hasEmbeddedFoo,
243252 bothColumnsShouldNotBeNullable: bothColumnsShouldNotBeNullable,
244- selectWithManyInputs: selectWithManyInputs
253+ selectWithManyInputs: selectWithManyInputs,
254+ inputIsArray: inputIsArray,
255+ inputContainsArray: inputContainsArray
245256 )
246257 }
247258
@@ -358,6 +369,39 @@ struct QueriesQueries: ConnectionWrapper, Sendable {
358369 try statement.bind(value: input.intPk, to: 1)
359370 try statement.bind(value: input.textNotNull, to: 2)
360371 return try statement.fetchOne(adapters: adapters)
372+ },
373+ inputIsArray: DatabaseQuery<[Int], ()>(
374+ .write,
375+ in: connection,
376+ watchingTables: ["bar"]
377+ ) { input, tx in
378+ let statement = try Otter.Statement(
379+ """
380+ DELETE FROM bar WHERE intPk IN (\(input.sqlQuestionMarks))
381+ """,
382+ transaction: tx
383+ )
384+ for element in input {
385+ try statement.bind(value: element, to: 1)
386+ }
387+ _ = try statement.step()
388+ },
389+ inputContainsArray: DatabaseQuery<InputContainsArrayInput, ()>(
390+ .write,
391+ in: connection,
392+ watchingTables: ["bar"]
393+ ) { input, tx in
394+ let statement = try Otter.Statement(
395+ """
396+ DELETE FROM bar WHERE intPk IN (\(input.intPks.sqlQuestionMarks))AND barNotNullText = ?
397+ """,
398+ transaction: tx
399+ )
400+ for element in input.intPks {
401+ try statement.bind(value: element, to: 1)
402+ }
403+ try statement.bind(value: input.barNotNullText, to: 2)
404+ _ = try statement.step()
361405 }
362406 )
363407 }
@@ -464,3 +508,19 @@ extension Query where Input == SelectWithManyInputsInput {
464508 observe(SelectWithManyInputsInput(intPk: intPk, textNotNull: textNotNull))
465509 }
466510}
511+
512+ typealias InputIsArrayQuery = Query<[Int], ()>
513+ typealias InputContainsArrayQuery = Query<InputContainsArrayInput, ()>
514+ extension Query where Input == InputContainsArrayInput {
515+ func execute(intPks: [Int], barNotNullText: String) async throws -> Output {
516+ try await execute(InputContainsArrayInput(intPks: intPks, barNotNullText: barNotNullText))
517+ }
518+
519+ func execute(intPks: [Int], barNotNullText: String, tx: borrowing Transaction) throws -> Output {
520+ try execute(InputContainsArrayInput(intPks: intPks, barNotNullText: barNotNullText), tx: tx)
521+ }
522+
523+ func observe(intPks: [Int], barNotNullText: String) -> QueryStream<Output> {
524+ observe(InputContainsArrayInput(intPks: intPks, barNotNullText: barNotNullText))
525+ }
526+ }
0 commit comments