Skip to content

Commit 034b241

Browse files
committed
Rename ColumnsProvider to DatabaseComponents
1 parent 814146c commit 034b241

15 files changed

+225
-213
lines changed

GRDB/QueryInterface/Request/Association/Association.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -305,13 +305,13 @@ extension AssociationToOne {
305305
///
306306
/// ### Building Association Aggregates
307307
///
308-
/// - ``average(_:)-1rl6m``
308+
/// - ``average(_:)-4n3up``
309309
/// - ``count``
310310
/// - ``isEmpty``
311-
/// - ``max(_:)-32xmj``
312-
/// - ``min(_:)-ulrg``
313-
/// - ``sum(_:)-8jd26``
314-
/// - ``total(_:)-9ae2u``
311+
/// - ``max(_:)-1upp8``
312+
/// - ``min(_:)-7xc49``
313+
/// - ``sum(_:)-5p74s``
314+
/// - ``total(_:)-hudm``
315315
///
316316
/// - ``AssociationAggregate``
317317
///

GRDB/QueryInterface/Request/Association/AssociationAggregate.swift

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,11 @@ extension AssociationToMany {
179179
/// }
180180
/// ```
181181
public func average(
182-
_ expression: (RowDecoder.ColumnsProvider) -> some SQLSpecificExpressible
182+
_ expression: (DatabaseComponents) -> some SQLSpecificExpressible
183183
) -> AssociationAggregate<OriginRowDecoder>
184184
where RowDecoder: TableRecord
185185
{
186-
average(expression(RowDecoder.columns))
186+
average(expression(RowDecoder.databaseComponents))
187187
}
188188

189189
/// Returns the maximum value of the given expression in associated records.
@@ -276,11 +276,11 @@ extension AssociationToMany {
276276
/// }
277277
/// ```
278278
public func max(
279-
_ expression: (RowDecoder.ColumnsProvider) -> some SQLSpecificExpressible
279+
_ expression: (DatabaseComponents) -> some SQLSpecificExpressible
280280
) -> AssociationAggregate<OriginRowDecoder>
281281
where RowDecoder: TableRecord
282282
{
283-
max(expression(RowDecoder.columns))
283+
max(expression(RowDecoder.databaseComponents))
284284
}
285285

286286
/// Returns the minimum value of the given expression in associated records.
@@ -373,11 +373,11 @@ extension AssociationToMany {
373373
/// }
374374
/// ```
375375
public func min(
376-
_ expression: (RowDecoder.ColumnsProvider) -> some SQLSpecificExpressible
376+
_ expression: (DatabaseComponents) -> some SQLSpecificExpressible
377377
) -> AssociationAggregate<OriginRowDecoder>
378378
where RowDecoder: TableRecord
379379
{
380-
min(expression(RowDecoder.columns))
380+
min(expression(RowDecoder.databaseComponents))
381381
}
382382

383383
/// Returns the sum of the given expression in associated records.
@@ -434,7 +434,7 @@ extension AssociationToMany {
434434
/// Returns the sum of the given expression in associated records.
435435
///
436436
/// This aggregate invokes the `SUM` SQL function.
437-
/// See also ``AssociationToMany/total(_:)-9ae2u`` and
437+
/// See also ``AssociationToMany/total(_:)-hudm`` and
438438
/// <https://www.sqlite.org/lang_aggfunc.html#sumunc>.
439439
///
440440
/// For example:
@@ -478,11 +478,11 @@ extension AssociationToMany {
478478
/// }
479479
/// ```
480480
public func sum(
481-
_ expression: (RowDecoder.ColumnsProvider) -> some SQLSpecificExpressible
481+
_ expression: (DatabaseComponents) -> some SQLSpecificExpressible
482482
) -> AssociationAggregate<OriginRowDecoder>
483483
where RowDecoder: TableRecord
484484
{
485-
sum(expression(RowDecoder.columns))
485+
sum(expression(RowDecoder.databaseComponents))
486486
}
487487

488488
/// Returns the sum of the given expression in associated records.
@@ -541,7 +541,7 @@ extension AssociationToMany {
541541
/// Returns the sum of the given expression in associated records.
542542
///
543543
/// This aggregate invokes the `TOTAL` SQL function.
544-
/// See also ``AssociationToMany/sum(_:)-8jd26`` and
544+
/// See also ``AssociationToMany/sum(_:)-5p74s`` and
545545
/// <https://www.sqlite.org/lang_aggfunc.html#sumunc>.
546546
///
547547
/// For example:
@@ -585,14 +585,18 @@ extension AssociationToMany {
585585
/// }
586586
/// ```
587587
public func total(
588-
_ expression: (RowDecoder.ColumnsProvider) -> some SQLSpecificExpressible
588+
_ expression: (DatabaseComponents) -> some SQLSpecificExpressible
589589
) -> AssociationAggregate<OriginRowDecoder>
590590
where RowDecoder: TableRecord
591591
{
592-
total(expression(RowDecoder.columns))
592+
total(expression(RowDecoder.databaseComponents))
593593
}
594594
}
595595

596+
extension AssociationToMany where RowDecoder: TableRecord {
597+
public typealias DatabaseComponents = RowDecoder.DatabaseComponents
598+
}
599+
596600
/// A value aggregated from a population of associated records.
597601
///
598602
/// You build an `AssociationAggregate` from an ``AssociationToMany``.

GRDB/QueryInterface/Request/QueryInterfaceRequest.swift

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
/// ### Changing The Type of Fetched Results
5858
///
5959
/// - ``asRequest(of:)``
60-
/// - ``select(_:as:)-58954``
60+
/// - ``select(_:as:)-74lsr``
6161
/// - ``select(literal:as:)``
6262
/// - ``select(sql:arguments:as:)``
6363
/// - ``selectID()``
@@ -228,7 +228,7 @@ extension QueryInterfaceRequest: SelectionRequest {
228228
///
229229
/// Any previous selection is discarded.
230230
public func select<T>(
231-
_ selection: (RowDecoder.ColumnsProvider) -> any SQLSelectable,
231+
_ selection: (DatabaseComponents) -> any SQLSelectable,
232232
as type: T.Type = T.self)
233233
-> QueryInterfaceRequest<T>
234234
where RowDecoder: TableRecord
@@ -591,6 +591,10 @@ extension QueryInterfaceRequest {
591591
}
592592
}
593593

594+
extension QueryInterfaceRequest where RowDecoder: TableRecord {
595+
public typealias DatabaseComponents = RowDecoder.DatabaseComponents
596+
}
597+
594598
// MARK: - Check Existence
595599

596600
extension QueryInterfaceRequest {
@@ -698,11 +702,11 @@ extension QueryInterfaceRequest {
698702
/// - precondition: The result of `select` is not empty.
699703
public func deleteAndFetchStatement(
700704
_ db: Database,
701-
select: (RowDecoder.ColumnsProvider) -> [any SQLSelectable])
705+
select: (DatabaseComponents) -> [any SQLSelectable])
702706
throws -> Statement
703707
where RowDecoder: TableRecord
704708
{
705-
try deleteAndFetchStatement(db, selection: select(RowDecoder.columns))
709+
try deleteAndFetchStatement(db, selection: select(RowDecoder.databaseComponents))
706710
}
707711

708712
/// Returns a cursor over the records deleted by a
@@ -883,11 +887,11 @@ extension QueryInterfaceRequest {
883887
@available(iOS 15, macOS 12, tvOS 15, watchOS 8, *) // SQLite 3.35.0+
884888
public func deleteAndFetchStatement(
885889
_ db: Database,
886-
select: (RowDecoder.ColumnsProvider) -> [any SQLSelectable])
890+
select: (DatabaseComponents) -> [any SQLSelectable])
887891
throws -> Statement
888892
where RowDecoder: TableRecord
889893
{
890-
try deleteAndFetchStatement(db, selection: select(RowDecoder.columns))
894+
try deleteAndFetchStatement(db, selection: select(RowDecoder.databaseComponents))
891895
}
892896

893897
/// Returns a cursor over the records deleted by a
@@ -1055,11 +1059,11 @@ extension QueryInterfaceRequest {
10551059
public func updateAll(
10561060
_ db: Database,
10571061
onConflict conflictResolution: Database.ConflictResolution? = nil,
1058-
assignment: (RowDecoder.ColumnsProvider) -> ColumnAssignment
1062+
assignment: (DatabaseComponents) -> ColumnAssignment
10591063
) throws -> Int
10601064
where RowDecoder: TableRecord
10611065
{
1062-
try updateAll(db, onConflict: conflictResolution, [assignment(RowDecoder.columns)])
1066+
try updateAll(db, onConflict: conflictResolution, [assignment(RowDecoder.databaseComponents)])
10631067
}
10641068

10651069
/// Updates matching rows, and returns the number of updated rows.
@@ -1090,11 +1094,11 @@ extension QueryInterfaceRequest {
10901094
public func updateAll(
10911095
_ db: Database,
10921096
onConflict conflictResolution: Database.ConflictResolution? = nil,
1093-
assignments: (RowDecoder.ColumnsProvider) -> [ColumnAssignment]
1097+
assignments: (DatabaseComponents) -> [ColumnAssignment]
10941098
) throws -> Int
10951099
where RowDecoder: TableRecord
10961100
{
1097-
try updateAll(db, onConflict: conflictResolution, assignments(RowDecoder.columns))
1101+
try updateAll(db, onConflict: conflictResolution, assignments(RowDecoder.databaseComponents))
10981102
}
10991103

11001104
/// Updates matching rows, and returns the number of updated rows.
@@ -1204,16 +1208,16 @@ extension QueryInterfaceRequest {
12041208
public func updateAndFetchStatement(
12051209
_ db: Database,
12061210
onConflict conflictResolution: Database.ConflictResolution? = nil,
1207-
assignments: (RowDecoder.ColumnsProvider) -> [ColumnAssignment],
1208-
select: (RowDecoder.ColumnsProvider) -> [any SQLSelectable])
1211+
assignments: (DatabaseComponents) -> [ColumnAssignment],
1212+
select: (DatabaseComponents) -> [any SQLSelectable])
12091213
throws -> Statement
12101214
where RowDecoder: TableRecord
12111215
{
12121216
try updateAndFetchStatement(
12131217
db,
12141218
onConflict: conflictResolution,
1215-
assignments(RowDecoder.columns),
1216-
selection: select(RowDecoder.columns))
1219+
assignments(RowDecoder.databaseComponents),
1220+
selection: select(RowDecoder.databaseComponents))
12171221
}
12181222

12191223
/// Returns an `UPDATE RETURNING` prepared statement.
@@ -1299,11 +1303,11 @@ extension QueryInterfaceRequest {
12991303
public func updateAndFetchCursor(
13001304
_ db: Database,
13011305
onConflict conflictResolution: Database.ConflictResolution? = nil,
1302-
assignments: (RowDecoder.ColumnsProvider) -> [ColumnAssignment])
1306+
assignments: (DatabaseComponents) -> [ColumnAssignment])
13031307
throws -> RecordCursor<RowDecoder>
13041308
where RowDecoder: FetchableRecord & TableRecord
13051309
{
1306-
try updateAndFetchCursor(db, onConflict: conflictResolution, assignments(RowDecoder.columns))
1310+
try updateAndFetchCursor(db, onConflict: conflictResolution, assignments(RowDecoder.databaseComponents))
13071311
}
13081312

13091313
/// Returns a cursor over the records updated by an
@@ -1378,11 +1382,11 @@ extension QueryInterfaceRequest {
13781382
public func updateAndFetchAll(
13791383
_ db: Database,
13801384
onConflict conflictResolution: Database.ConflictResolution? = nil,
1381-
assignments: (RowDecoder.ColumnsProvider) -> [ColumnAssignment])
1385+
assignments: (DatabaseComponents) -> [ColumnAssignment])
13821386
throws -> [RowDecoder]
13831387
where RowDecoder: FetchableRecord & TableRecord
13841388
{
1385-
try updateAndFetchAll(db, onConflict: conflictResolution, assignments(RowDecoder.columns))
1389+
try updateAndFetchAll(db, onConflict: conflictResolution, assignments(RowDecoder.databaseComponents))
13861390
}
13871391

13881392
/// Execute an `UPDATE RETURNING` statement and returns the array of
@@ -1449,11 +1453,11 @@ extension QueryInterfaceRequest {
14491453
public func updateAndFetchSet(
14501454
_ db: Database,
14511455
onConflict conflictResolution: Database.ConflictResolution? = nil,
1452-
assignments: (RowDecoder.ColumnsProvider) -> [ColumnAssignment])
1456+
assignments: (DatabaseComponents) -> [ColumnAssignment])
14531457
throws -> Set<RowDecoder>
14541458
where RowDecoder: FetchableRecord & TableRecord & Hashable
14551459
{
1456-
try updateAndFetchSet(db, onConflict: conflictResolution, assignments(RowDecoder.columns))
1460+
try updateAndFetchSet(db, onConflict: conflictResolution, assignments(RowDecoder.databaseComponents))
14571461
}
14581462

14591463
/// Execute an `UPDATE RETURNING` statement and returns the set of
@@ -1528,16 +1532,16 @@ extension QueryInterfaceRequest {
15281532
public func updateAndFetchStatement(
15291533
_ db: Database,
15301534
onConflict conflictResolution: Database.ConflictResolution? = nil,
1531-
assignments: (RowDecoder.ColumnsProvider) -> [ColumnAssignment],
1532-
select: (RowDecoder.ColumnsProvider) -> [any SQLSelectable])
1535+
assignments: (DatabaseComponents) -> [ColumnAssignment],
1536+
select: (DatabaseComponents) -> [any SQLSelectable])
15331537
throws -> Statement
15341538
where RowDecoder: TableRecord
15351539
{
15361540
try updateAndFetchStatement(
15371541
db,
15381542
onConflict: conflictResolution,
1539-
assignments(RowDecoder.columns),
1540-
selection: select(RowDecoder.columns))
1543+
assignments(RowDecoder.databaseComponents),
1544+
selection: select(RowDecoder.databaseComponents))
15411545
}
15421546

15431547
/// Returns an `UPDATE RETURNING` prepared statement.
@@ -1625,11 +1629,11 @@ extension QueryInterfaceRequest {
16251629
public func updateAndFetchCursor(
16261630
_ db: Database,
16271631
onConflict conflictResolution: Database.ConflictResolution? = nil,
1628-
assignments: (RowDecoder.ColumnsProvider) -> [ColumnAssignment])
1632+
assignments: (DatabaseComponents) -> [ColumnAssignment])
16291633
throws -> RecordCursor<RowDecoder>
16301634
where RowDecoder: FetchableRecord & TableRecord
16311635
{
1632-
try updateAndFetchCursor(db, onConflict: conflictResolution, assignments(RowDecoder.columns))
1636+
try updateAndFetchCursor(db, onConflict: conflictResolution, assignments(RowDecoder.databaseComponents))
16331637
}
16341638

16351639
/// Returns a cursor over the records updated by an
@@ -1706,11 +1710,11 @@ extension QueryInterfaceRequest {
17061710
public func updateAndFetchAll(
17071711
_ db: Database,
17081712
onConflict conflictResolution: Database.ConflictResolution? = nil,
1709-
assignments: (RowDecoder.ColumnsProvider) -> [ColumnAssignment])
1713+
assignments: (DatabaseComponents) -> [ColumnAssignment])
17101714
throws -> [RowDecoder]
17111715
where RowDecoder: FetchableRecord & TableRecord
17121716
{
1713-
try updateAndFetchAll(db, onConflict: conflictResolution, assignments(RowDecoder.columns))
1717+
try updateAndFetchAll(db, onConflict: conflictResolution, assignments(RowDecoder.databaseComponents))
17141718
}
17151719

17161720
/// Execute an `UPDATE RETURNING` statement and returns the array of
@@ -1779,11 +1783,11 @@ extension QueryInterfaceRequest {
17791783
public func updateAndFetchSet(
17801784
_ db: Database,
17811785
onConflict conflictResolution: Database.ConflictResolution? = nil,
1782-
assignments: (RowDecoder.ColumnsProvider) -> [ColumnAssignment])
1786+
assignments: (DatabaseComponents) -> [ColumnAssignment])
17831787
throws -> Set<RowDecoder>
17841788
where RowDecoder: FetchableRecord & TableRecord & Hashable
17851789
{
1786-
try updateAndFetchSet(db, onConflict: conflictResolution, assignments(RowDecoder.columns))
1790+
try updateAndFetchSet(db, onConflict: conflictResolution, assignments(RowDecoder.databaseComponents))
17871791
}
17881792

17891793
/// Execute an `UPDATE RETURNING` statement and returns the set of

0 commit comments

Comments
 (0)