@@ -88,7 +88,17 @@ extension PrimaryKeyedTable {
8888 public static func find(
8989 _ primaryKey: some QueryExpression < TableColumns . PrimaryKey >
9090 ) -> Where < Self > {
91- Self . where { $0. primaryKey. eq ( primaryKey) }
91+ Self . find ( [ primaryKey] )
92+ }
93+
94+ /// A where clause filtered by primary keys.
95+ ///
96+ /// - Parameter primaryKey: Primary keys identifying table rows.
97+ /// - Returns: A `WHERE` clause.
98+ public static func find(
99+ _ primaryKeys: some Sequence < some QueryExpression < TableColumns . PrimaryKey > >
100+ ) -> Where < Self > {
101+ Self . where { $0. primaryKey. in ( primaryKeys) }
92102 }
93103
94104 public var primaryKey : PrimaryKey . QueryOutput {
@@ -104,9 +114,17 @@ extension TableDraft {
104114 public static func find(
105115 _ primaryKey: some QueryExpression < PrimaryTable . TableColumns . PrimaryKey >
106116 ) -> Where < Self > {
107- Self . where { _ in
108- PrimaryTable . columns. primaryKey. eq ( primaryKey)
109- }
117+ Self . find ( [ primaryKey] )
118+ }
119+
120+ /// A where clause filtered by primary keys.
121+ ///
122+ /// - Parameter primaryKeys: Primary keys identifying table rows.
123+ /// - Returns: A `WHERE` clause.
124+ public static func find(
125+ _ primaryKeys: some Sequence < some QueryExpression < PrimaryTable . TableColumns . PrimaryKey > >
126+ ) -> Where < Self > {
127+ Self . where { $0. primaryKey. in ( primaryKeys) }
110128 }
111129}
112130
@@ -116,7 +134,17 @@ extension Where where From: PrimaryKeyedTable {
116134 /// - Parameter primaryKey: A primary key.
117135 /// - Returns: A where clause with the added primary key.
118136 public func find( _ primaryKey: some QueryExpression < From . TableColumns . PrimaryKey > ) -> Self {
119- self . where { $0. primaryKey. eq ( primaryKey) }
137+ self . find ( [ primaryKey] )
138+ }
139+
140+ /// Adds a primary key condition to a where clause.
141+ ///
142+ /// - Parameter primaryKeys: A sequence of primary keys.
143+ /// - Returns: A where clause with the added primary keys condition.
144+ public func find(
145+ _ primaryKeys: some Sequence < some QueryExpression < From . TableColumns . PrimaryKey > >
146+ ) -> Self {
147+ Self . where { $0. primaryKey. in ( primaryKeys) }
120148 }
121149}
122150
@@ -125,12 +153,18 @@ extension Where where From: TableDraft {
125153 ///
126154 /// - Parameter primaryKey: A primary key.
127155 /// - Returns: A where clause with the added primary key.
128- public func find( _ primaryKey: From . PrimaryTable . TableColumns . PrimaryKey . QueryOutput ) -> Self {
129- self . where { _ in
130- From . PrimaryTable. columns. primaryKey. eq (
131- From . PrimaryTable. TableColumns. PrimaryKey ( queryOutput: primaryKey)
132- )
133- }
156+ public func find( _ primaryKey: some QueryExpression < From . PrimaryTable . TableColumns . PrimaryKey > ) -> Self {
157+ self . find ( [ primaryKey] )
158+ }
159+
160+ /// Adds a primary key condition to a where clause.
161+ ///
162+ /// - Parameter primaryKeys: A sequence of primary keys.
163+ /// - Returns: A where clause with the added primary keys condition.
164+ public func find(
165+ _ primaryKeys: some Sequence < some QueryExpression < From . PrimaryTable . TableColumns . PrimaryKey > >
166+ ) -> Self {
167+ Self . where { $0. primaryKey. in ( primaryKeys) }
134168 }
135169}
136170
@@ -142,6 +176,16 @@ extension Select where From: PrimaryKeyedTable {
142176 public func find( _ primaryKey: some QueryExpression < From . TableColumns . PrimaryKey > ) -> Self {
143177 self . and ( From . find ( primaryKey) )
144178 }
179+
180+ /// A select statement filtered by a sequence of primary keys.
181+ ///
182+ /// - Parameter primaryKeys: A sequence of primary keys.
183+ /// - Returns: A select statement filtered by the given keys.
184+ public func find(
185+ _ primaryKeys: some Sequence < some QueryExpression < From . TableColumns . PrimaryKey > >
186+ ) -> Self {
187+ self . and ( From . find ( primaryKeys) )
188+ }
145189}
146190
147191extension Select where From: TableDraft {
@@ -154,6 +198,16 @@ extension Select where From: TableDraft {
154198 ) -> Self {
155199 self . and ( From . find ( primaryKey) )
156200 }
201+
202+ /// A select statement filtered by a sequence of primary keys.
203+ ///
204+ /// - Parameter primaryKeys: A sequence of primary keys.
205+ /// - Returns: A select statement filtered by the given keys.
206+ public func find(
207+ _ primaryKeys: some Sequence < some QueryExpression < From . PrimaryTable . TableColumns . PrimaryKey > >
208+ ) -> Self {
209+ self . and ( From . find ( primaryKeys) )
210+ }
157211}
158212
159213extension Update where From: PrimaryKeyedTable {
@@ -162,7 +216,17 @@ extension Update where From: PrimaryKeyedTable {
162216 /// - Parameter primaryKey: A primary key identifying a table row.
163217 /// - Returns: An update statement filtered by the given key.
164218 public func find( _ primaryKey: some QueryExpression < From . TableColumns . PrimaryKey > ) -> Self {
165- self . where { $0. primaryKey. eq ( primaryKey) }
219+ self . find ( [ primaryKey] )
220+ }
221+
222+ /// An update statement filtered by a sequence of primary keys.
223+ ///
224+ /// - Parameter primaryKeys: A sequence of primary keys.
225+ /// - Returns: An update statement filtered by the given keys.
226+ public func find(
227+ _ primaryKeys: some Sequence < some QueryExpression < From . TableColumns . PrimaryKey > >
228+ ) -> Self {
229+ self . where { $0. primaryKey. in ( primaryKeys) }
166230 }
167231}
168232
@@ -171,12 +235,18 @@ extension Update where From: TableDraft {
171235 ///
172236 /// - Parameter primaryKey: A primary key identifying a table row.
173237 /// - Returns: An update statement filtered by the given key.
174- public func find( _ primaryKey: From . PrimaryTable . TableColumns . PrimaryKey . QueryOutput ) -> Self {
175- self . where { _ in
176- From . PrimaryTable. columns. primaryKey. eq (
177- From . PrimaryTable. TableColumns. PrimaryKey ( queryOutput: primaryKey)
178- )
179- }
238+ public func find( _ primaryKey: some QueryExpression < From . PrimaryTable . TableColumns . PrimaryKey > ) -> Self {
239+ self . find ( [ primaryKey] )
240+ }
241+
242+ /// An update statement filtered by a sequence of primary keys.
243+ ///
244+ /// - Parameter primaryKeys: A sequence of primary keys.
245+ /// - Returns: An update statement filtered by the given keys.
246+ public func find(
247+ _ primaryKeys: some Sequence < some QueryExpression < From . PrimaryTable . TableColumns . PrimaryKey > >
248+ ) -> Self {
249+ self . where { $0. primaryKey. in ( primaryKeys) }
180250 }
181251}
182252
@@ -186,7 +256,17 @@ extension Delete where From: PrimaryKeyedTable {
186256 /// - Parameter primaryKey: A primary key identifying a table row.
187257 /// - Returns: A delete statement filtered by the given key.
188258 public func find( _ primaryKey: some QueryExpression < From . TableColumns . PrimaryKey > ) -> Self {
189- self . where { $0. primaryKey. eq ( primaryKey) }
259+ self . find ( [ primaryKey] )
260+ }
261+
262+ /// A delete statement filtered by a sequence of primary keys.
263+ ///
264+ /// - Parameter primaryKeys: A sequence of primary keys.
265+ /// - Returns: A delete statement filtered by the given keys.
266+ public func find(
267+ _ primaryKeys: some Sequence < some QueryExpression < From . TableColumns . PrimaryKey > >
268+ ) -> Self {
269+ self . where { $0. primaryKey. in ( primaryKeys) }
190270 }
191271}
192272
@@ -195,11 +275,17 @@ extension Delete where From: TableDraft {
195275 ///
196276 /// - Parameter primaryKey: A primary key identifying a table row.
197277 /// - Returns: A delete statement filtered by the given key.
198- public func find( _ primaryKey: From . PrimaryTable . TableColumns . PrimaryKey . QueryOutput ) -> Self {
199- self . where { _ in
200- From . PrimaryTable. columns. primaryKey. eq (
201- From . PrimaryTable. TableColumns. PrimaryKey ( queryOutput: primaryKey)
202- )
203- }
278+ public func find( _ primaryKey: some QueryExpression < From . PrimaryTable . TableColumns . PrimaryKey > ) -> Self {
279+ self . find ( [ primaryKey] )
280+ }
281+
282+ /// A delete statement filtered by a sequence of primary keys.
283+ ///
284+ /// - Parameter primaryKeys: A sequence of primary keys.
285+ /// - Returns: A delete statement filtered by the given keys.
286+ public func find(
287+ _ primaryKeys: some Sequence < some QueryExpression < From . PrimaryTable . TableColumns . PrimaryKey > >
288+ ) -> Self {
289+ self . where { $0. primaryKey. in ( primaryKeys) }
204290 }
205291}
0 commit comments