mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-30 04:28:44 +00:00
Merge pull request #1768 from groue/dev/throwing-closures
All closures that accept DatabaseComponents can throw
This commit is contained in:
9 files changed
+150
-152
No files matched your search
@@ -305,13 +305,13 @@ extension AssociationToOne {
|
||||
///
|
||||
/// ### Building Association Aggregates
|
||||
///
|
||||
/// - ``average(_:)-4n3up``
|
||||
/// - ``average(_:)-1ehdb``
|
||||
/// - ``count``
|
||||
/// - ``isEmpty``
|
||||
/// - ``max(_:)-1upp8``
|
||||
/// - ``min(_:)-7xc49``
|
||||
/// - ``sum(_:)-5p74s``
|
||||
/// - ``total(_:)-hudm``
|
||||
/// - ``max(_:)-a32j``
|
||||
/// - ``min(_:)-41jp8``
|
||||
/// - ``sum(_:)-47yg7``
|
||||
/// - ``total(_:)-6dd9d``
|
||||
///
|
||||
/// - ``AssociationAggregate``
|
||||
///
|
||||
|
||||
@@ -179,11 +179,11 @@ extension AssociationToMany {
|
||||
/// }
|
||||
/// ```
|
||||
public func average(
|
||||
_ expression: (DatabaseComponents) -> some SQLSpecificExpressible
|
||||
) -> AssociationAggregate<OriginRowDecoder>
|
||||
_ expression: (DatabaseComponents) throws -> some SQLSpecificExpressible
|
||||
) rethrows -> AssociationAggregate<OriginRowDecoder>
|
||||
where RowDecoder: TableRecord
|
||||
{
|
||||
average(expression(RowDecoder.databaseComponents))
|
||||
try average(expression(RowDecoder.databaseComponents))
|
||||
}
|
||||
|
||||
/// Returns the maximum value of the given expression in associated records.
|
||||
@@ -276,11 +276,11 @@ extension AssociationToMany {
|
||||
/// }
|
||||
/// ```
|
||||
public func max(
|
||||
_ expression: (DatabaseComponents) -> some SQLSpecificExpressible
|
||||
) -> AssociationAggregate<OriginRowDecoder>
|
||||
_ expression: (DatabaseComponents) throws -> some SQLSpecificExpressible
|
||||
) rethrows -> AssociationAggregate<OriginRowDecoder>
|
||||
where RowDecoder: TableRecord
|
||||
{
|
||||
max(expression(RowDecoder.databaseComponents))
|
||||
try max(expression(RowDecoder.databaseComponents))
|
||||
}
|
||||
|
||||
/// Returns the minimum value of the given expression in associated records.
|
||||
@@ -373,11 +373,11 @@ extension AssociationToMany {
|
||||
/// }
|
||||
/// ```
|
||||
public func min(
|
||||
_ expression: (DatabaseComponents) -> some SQLSpecificExpressible
|
||||
) -> AssociationAggregate<OriginRowDecoder>
|
||||
_ expression: (DatabaseComponents) throws -> some SQLSpecificExpressible
|
||||
) rethrows -> AssociationAggregate<OriginRowDecoder>
|
||||
where RowDecoder: TableRecord
|
||||
{
|
||||
min(expression(RowDecoder.databaseComponents))
|
||||
try min(expression(RowDecoder.databaseComponents))
|
||||
}
|
||||
|
||||
/// Returns the sum of the given expression in associated records.
|
||||
@@ -434,7 +434,7 @@ extension AssociationToMany {
|
||||
/// Returns the sum of the given expression in associated records.
|
||||
///
|
||||
/// This aggregate invokes the `SUM` SQL function.
|
||||
/// See also ``AssociationToMany/total(_:)-hudm`` and
|
||||
/// See also ``AssociationToMany/total(_:)-6dd9d`` and
|
||||
/// <https://www.sqlite.org/lang_aggfunc.html#sumunc>.
|
||||
///
|
||||
/// For example:
|
||||
@@ -478,11 +478,11 @@ extension AssociationToMany {
|
||||
/// }
|
||||
/// ```
|
||||
public func sum(
|
||||
_ expression: (DatabaseComponents) -> some SQLSpecificExpressible
|
||||
) -> AssociationAggregate<OriginRowDecoder>
|
||||
_ expression: (DatabaseComponents) throws -> some SQLSpecificExpressible
|
||||
) rethrows -> AssociationAggregate<OriginRowDecoder>
|
||||
where RowDecoder: TableRecord
|
||||
{
|
||||
sum(expression(RowDecoder.databaseComponents))
|
||||
try sum(expression(RowDecoder.databaseComponents))
|
||||
}
|
||||
|
||||
/// Returns the sum of the given expression in associated records.
|
||||
@@ -541,7 +541,7 @@ extension AssociationToMany {
|
||||
/// Returns the sum of the given expression in associated records.
|
||||
///
|
||||
/// This aggregate invokes the `TOTAL` SQL function.
|
||||
/// See also ``AssociationToMany/sum(_:)-5p74s`` and
|
||||
/// See also ``AssociationToMany/sum(_:)-47yg7`` and
|
||||
/// <https://www.sqlite.org/lang_aggfunc.html#sumunc>.
|
||||
///
|
||||
/// For example:
|
||||
@@ -585,11 +585,11 @@ extension AssociationToMany {
|
||||
/// }
|
||||
/// ```
|
||||
public func total(
|
||||
_ expression: (DatabaseComponents) -> some SQLSpecificExpressible
|
||||
) -> AssociationAggregate<OriginRowDecoder>
|
||||
_ expression: (DatabaseComponents) throws -> some SQLSpecificExpressible
|
||||
) rethrows -> AssociationAggregate<OriginRowDecoder>
|
||||
where RowDecoder: TableRecord
|
||||
{
|
||||
total(expression(RowDecoder.databaseComponents))
|
||||
try total(expression(RowDecoder.databaseComponents))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
/// ### Changing The Type of Fetched Results
|
||||
///
|
||||
/// - ``asRequest(of:)``
|
||||
/// - ``select(_:as:)-74lsr``
|
||||
/// - ``select(_:as:)-4cj9h``
|
||||
/// - ``select(literal:as:)``
|
||||
/// - ``select(sql:arguments:as:)``
|
||||
/// - ``selectID()``
|
||||
@@ -228,12 +228,12 @@ extension QueryInterfaceRequest: SelectionRequest {
|
||||
///
|
||||
/// Any previous selection is discarded.
|
||||
public func select<T>(
|
||||
_ selection: (DatabaseComponents) -> any SQLSelectable,
|
||||
as type: T.Type = T.self)
|
||||
-> QueryInterfaceRequest<T>
|
||||
_ selection: (DatabaseComponents) throws -> any SQLSelectable,
|
||||
as type: T.Type = T.self
|
||||
) rethrows -> QueryInterfaceRequest<T>
|
||||
where RowDecoder: TableRecord
|
||||
{
|
||||
select(selection).asRequest(of: T.self)
|
||||
try select(selection).asRequest(of: T.self)
|
||||
}
|
||||
|
||||
/// Defines the result columns with an SQL string, and defines the type of
|
||||
@@ -702,8 +702,8 @@ extension QueryInterfaceRequest {
|
||||
/// - precondition: The result of `select` is not empty.
|
||||
public func deleteAndFetchStatement(
|
||||
_ db: Database,
|
||||
select: (DatabaseComponents) -> [any SQLSelectable])
|
||||
throws -> Statement
|
||||
select: (DatabaseComponents) throws -> [any SQLSelectable]
|
||||
) throws -> Statement
|
||||
where RowDecoder: TableRecord
|
||||
{
|
||||
try deleteAndFetchStatement(db, selection: select(RowDecoder.databaseComponents))
|
||||
@@ -887,8 +887,8 @@ extension QueryInterfaceRequest {
|
||||
@available(iOS 15, macOS 12, tvOS 15, watchOS 8, *) // SQLite 3.35.0+
|
||||
public func deleteAndFetchStatement(
|
||||
_ db: Database,
|
||||
select: (DatabaseComponents) -> [any SQLSelectable])
|
||||
throws -> Statement
|
||||
select: (DatabaseComponents) throws -> [any SQLSelectable]
|
||||
) throws -> Statement
|
||||
where RowDecoder: TableRecord
|
||||
{
|
||||
try deleteAndFetchStatement(db, selection: select(RowDecoder.databaseComponents))
|
||||
@@ -1059,7 +1059,7 @@ extension QueryInterfaceRequest {
|
||||
public func updateAll(
|
||||
_ db: Database,
|
||||
onConflict conflictResolution: Database.ConflictResolution? = nil,
|
||||
assignment: (DatabaseComponents) -> ColumnAssignment
|
||||
assignment: (DatabaseComponents) throws -> ColumnAssignment
|
||||
) throws -> Int
|
||||
where RowDecoder: TableRecord
|
||||
{
|
||||
@@ -1094,7 +1094,7 @@ extension QueryInterfaceRequest {
|
||||
public func updateAll(
|
||||
_ db: Database,
|
||||
onConflict conflictResolution: Database.ConflictResolution? = nil,
|
||||
assignments: (DatabaseComponents) -> [ColumnAssignment]
|
||||
assignments: (DatabaseComponents) throws -> [ColumnAssignment]
|
||||
) throws -> Int
|
||||
where RowDecoder: TableRecord
|
||||
{
|
||||
@@ -1208,9 +1208,9 @@ extension QueryInterfaceRequest {
|
||||
public func updateAndFetchStatement(
|
||||
_ db: Database,
|
||||
onConflict conflictResolution: Database.ConflictResolution? = nil,
|
||||
assignments: (DatabaseComponents) -> [ColumnAssignment],
|
||||
select: (DatabaseComponents) -> [any SQLSelectable])
|
||||
throws -> Statement
|
||||
assignments: (DatabaseComponents) throws -> [ColumnAssignment],
|
||||
select: (DatabaseComponents) -> [any SQLSelectable]
|
||||
) throws -> Statement
|
||||
where RowDecoder: TableRecord
|
||||
{
|
||||
try updateAndFetchStatement(
|
||||
@@ -1303,8 +1303,8 @@ extension QueryInterfaceRequest {
|
||||
public func updateAndFetchCursor(
|
||||
_ db: Database,
|
||||
onConflict conflictResolution: Database.ConflictResolution? = nil,
|
||||
assignments: (DatabaseComponents) -> [ColumnAssignment])
|
||||
throws -> RecordCursor<RowDecoder>
|
||||
assignments: (DatabaseComponents) throws -> [ColumnAssignment]
|
||||
) throws -> RecordCursor<RowDecoder>
|
||||
where RowDecoder: FetchableRecord & TableRecord
|
||||
{
|
||||
try updateAndFetchCursor(db, onConflict: conflictResolution, assignments(RowDecoder.databaseComponents))
|
||||
@@ -1382,8 +1382,8 @@ extension QueryInterfaceRequest {
|
||||
public func updateAndFetchAll(
|
||||
_ db: Database,
|
||||
onConflict conflictResolution: Database.ConflictResolution? = nil,
|
||||
assignments: (DatabaseComponents) -> [ColumnAssignment])
|
||||
throws -> [RowDecoder]
|
||||
assignments: (DatabaseComponents) throws -> [ColumnAssignment]
|
||||
) throws -> [RowDecoder]
|
||||
where RowDecoder: FetchableRecord & TableRecord
|
||||
{
|
||||
try updateAndFetchAll(db, onConflict: conflictResolution, assignments(RowDecoder.databaseComponents))
|
||||
@@ -1453,8 +1453,8 @@ extension QueryInterfaceRequest {
|
||||
public func updateAndFetchSet(
|
||||
_ db: Database,
|
||||
onConflict conflictResolution: Database.ConflictResolution? = nil,
|
||||
assignments: (DatabaseComponents) -> [ColumnAssignment])
|
||||
throws -> Set<RowDecoder>
|
||||
assignments: (DatabaseComponents) throws -> [ColumnAssignment]
|
||||
) throws -> Set<RowDecoder>
|
||||
where RowDecoder: FetchableRecord & TableRecord & Hashable
|
||||
{
|
||||
try updateAndFetchSet(db, onConflict: conflictResolution, assignments(RowDecoder.databaseComponents))
|
||||
@@ -1532,9 +1532,9 @@ extension QueryInterfaceRequest {
|
||||
public func updateAndFetchStatement(
|
||||
_ db: Database,
|
||||
onConflict conflictResolution: Database.ConflictResolution? = nil,
|
||||
assignments: (DatabaseComponents) -> [ColumnAssignment],
|
||||
select: (DatabaseComponents) -> [any SQLSelectable])
|
||||
throws -> Statement
|
||||
assignments: (DatabaseComponents) throws -> [ColumnAssignment],
|
||||
select: (DatabaseComponents) throws -> [any SQLSelectable]
|
||||
) throws -> Statement
|
||||
where RowDecoder: TableRecord
|
||||
{
|
||||
try updateAndFetchStatement(
|
||||
@@ -1629,8 +1629,8 @@ extension QueryInterfaceRequest {
|
||||
public func updateAndFetchCursor(
|
||||
_ db: Database,
|
||||
onConflict conflictResolution: Database.ConflictResolution? = nil,
|
||||
assignments: (DatabaseComponents) -> [ColumnAssignment])
|
||||
throws -> RecordCursor<RowDecoder>
|
||||
assignments: (DatabaseComponents) throws -> [ColumnAssignment]
|
||||
) throws -> RecordCursor<RowDecoder>
|
||||
where RowDecoder: FetchableRecord & TableRecord
|
||||
{
|
||||
try updateAndFetchCursor(db, onConflict: conflictResolution, assignments(RowDecoder.databaseComponents))
|
||||
@@ -1710,8 +1710,8 @@ extension QueryInterfaceRequest {
|
||||
public func updateAndFetchAll(
|
||||
_ db: Database,
|
||||
onConflict conflictResolution: Database.ConflictResolution? = nil,
|
||||
assignments: (DatabaseComponents) -> [ColumnAssignment])
|
||||
throws -> [RowDecoder]
|
||||
assignments: (DatabaseComponents) throws -> [ColumnAssignment]
|
||||
) throws -> [RowDecoder]
|
||||
where RowDecoder: FetchableRecord & TableRecord
|
||||
{
|
||||
try updateAndFetchAll(db, onConflict: conflictResolution, assignments(RowDecoder.databaseComponents))
|
||||
@@ -1783,8 +1783,8 @@ extension QueryInterfaceRequest {
|
||||
public func updateAndFetchSet(
|
||||
_ db: Database,
|
||||
onConflict conflictResolution: Database.ConflictResolution? = nil,
|
||||
assignments: (DatabaseComponents) -> [ColumnAssignment])
|
||||
throws -> Set<RowDecoder>
|
||||
assignments: (DatabaseComponents) throws -> [ColumnAssignment]
|
||||
) throws -> Set<RowDecoder>
|
||||
where RowDecoder: FetchableRecord & TableRecord & Hashable
|
||||
{
|
||||
try updateAndFetchSet(db, onConflict: conflictResolution, assignments(RowDecoder.databaseComponents))
|
||||
|
||||
@@ -22,11 +22,11 @@ public protocol TypedRequest<RowDecoder> {
|
||||
///
|
||||
/// ### The SELECT Clause
|
||||
///
|
||||
/// - ``annotated(with:)-56y26``
|
||||
/// - ``annotated(with:)-9nuwi``
|
||||
/// - ``annotated(with:)-9wodv``
|
||||
/// - ``annotated(with:)-69r3``
|
||||
/// - ``annotatedWhenConnected(with:)``
|
||||
/// - ``select(_:)-90gu2``
|
||||
/// - ``select(_:)-4iv1w``
|
||||
/// - ``select(_:)-270ge``
|
||||
/// - ``select(_:)-4jw13``
|
||||
/// - ``select(literal:)``
|
||||
/// - ``select(sql:arguments:)``
|
||||
/// - ``selectWhenConnected(_:)``
|
||||
@@ -246,9 +246,9 @@ extension SelectionRequest where Self: TypedRequest, Self.RowDecoder: TableRecor
|
||||
/// .select(\.score)
|
||||
/// ```
|
||||
public func select(
|
||||
_ selection: (DatabaseComponents) -> any SQLSelectable
|
||||
) -> Self {
|
||||
select(selection(Self.RowDecoder.databaseComponents))
|
||||
_ selection: (DatabaseComponents) throws -> any SQLSelectable
|
||||
) rethrows -> Self {
|
||||
try select(selection(Self.RowDecoder.databaseComponents))
|
||||
}
|
||||
|
||||
/// Defines the result columns.
|
||||
@@ -276,9 +276,9 @@ extension SelectionRequest where Self: TypedRequest, Self.RowDecoder: TableRecor
|
||||
/// .select { [$0.score] }
|
||||
/// ```
|
||||
public func select(
|
||||
_ selection: (DatabaseComponents) -> [any SQLSelectable]
|
||||
) -> Self {
|
||||
select(selection(Self.RowDecoder.databaseComponents))
|
||||
_ selection: (DatabaseComponents) throws -> [any SQLSelectable]
|
||||
) rethrows -> Self {
|
||||
try select(selection(Self.RowDecoder.databaseComponents))
|
||||
}
|
||||
|
||||
/// Appends a result column to the selected columns.
|
||||
@@ -302,9 +302,9 @@ extension SelectionRequest where Self: TypedRequest, Self.RowDecoder: TableRecor
|
||||
/// - parameter selection: A closure that accepts a database connection and
|
||||
/// returns an array of result columns.
|
||||
public func annotated(
|
||||
with selection: (DatabaseComponents) -> any SQLSelectable
|
||||
) -> Self {
|
||||
annotated(with: selection(Self.RowDecoder.databaseComponents))
|
||||
with selection: (DatabaseComponents) throws -> any SQLSelectable
|
||||
) rethrows -> Self {
|
||||
try annotated(with: selection(Self.RowDecoder.databaseComponents))
|
||||
}
|
||||
|
||||
/// Appends result columns to the selected columns.
|
||||
@@ -328,9 +328,9 @@ extension SelectionRequest where Self: TypedRequest, Self.RowDecoder: TableRecor
|
||||
/// - parameter selection: A closure that accepts a database connection and
|
||||
/// returns an array of result columns.
|
||||
public func annotated(
|
||||
with selection: (DatabaseComponents) -> [any SQLSelectable]
|
||||
) -> Self {
|
||||
annotated(with: selection(Self.RowDecoder.databaseComponents))
|
||||
with selection: (DatabaseComponents) throws -> [any SQLSelectable]
|
||||
) rethrows -> Self {
|
||||
try annotated(with: selection(Self.RowDecoder.databaseComponents))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -346,7 +346,7 @@ extension SelectionRequest where Self: TypedRequest, Self.RowDecoder: TableRecor
|
||||
/// ### The WHERE and JOIN ON Clauses
|
||||
///
|
||||
/// - ``all()``
|
||||
/// - ``filter(_:)-5l0gu``
|
||||
/// - ``filter(_:)-7j0nw``
|
||||
/// - ``filter(literal:)``
|
||||
/// - ``filter(sql:arguments:)``
|
||||
/// - ``filterWhenConnected(_:)``
|
||||
@@ -463,9 +463,9 @@ extension FilteredRequest where Self: TypedRequest, Self.RowDecoder: TableRecord
|
||||
/// let request = Player.all().filter { $0.name == name }
|
||||
/// ```
|
||||
public func filter(
|
||||
_ predicate: (DatabaseComponents) -> any SQLSpecificExpressible
|
||||
) -> Self {
|
||||
filter(predicate(Self.RowDecoder.databaseComponents))
|
||||
_ predicate: (DatabaseComponents) throws -> any SQLSpecificExpressible
|
||||
) rethrows -> Self {
|
||||
try filter(predicate(Self.RowDecoder.databaseComponents))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -964,15 +964,15 @@ extension TableRequest where Self: AggregatingRequest {
|
||||
///
|
||||
/// ### The GROUP BY Clause
|
||||
///
|
||||
/// - ``group(_:)-9z116``
|
||||
/// - ``group(_:)-43p07``
|
||||
/// - ``group(_:)-5soxm``
|
||||
/// - ``group(_:)-32exm``
|
||||
/// - ``group(literal:)``
|
||||
/// - ``group(sql:arguments:)``
|
||||
/// - ``groupWhenConnected(_:)``
|
||||
///
|
||||
/// ### The HAVING Clause
|
||||
///
|
||||
/// - ``having(_:)-6zfvb``
|
||||
/// - ``having(_:)-27hlo``
|
||||
/// - ``having(literal:)``
|
||||
/// - ``having(sql:arguments:)``
|
||||
/// - ``havingWhenConnected(_:)``
|
||||
@@ -1199,16 +1199,16 @@ extension AggregatingRequest where Self: TypedRequest, Self.RowDecoder: TableRec
|
||||
///
|
||||
/// Any previous grouping is discarded.
|
||||
public func group(
|
||||
_ expression: (DatabaseComponents) -> any SQLExpressible
|
||||
) -> Self {
|
||||
group(expression(Self.RowDecoder.databaseComponents))
|
||||
_ expression: (DatabaseComponents) throws -> any SQLExpressible
|
||||
) rethrows -> Self {
|
||||
try group(expression(Self.RowDecoder.databaseComponents))
|
||||
}
|
||||
|
||||
/// Returns an aggregate request grouped on the given SQL expressions.
|
||||
public func group(
|
||||
_ expressions: (DatabaseComponents) -> [any SQLExpressible]
|
||||
) -> Self {
|
||||
group(expressions(Self.RowDecoder.databaseComponents))
|
||||
_ expressions: (DatabaseComponents) throws -> [any SQLExpressible]
|
||||
) rethrows -> Self {
|
||||
try group(expressions(Self.RowDecoder.databaseComponents))
|
||||
}
|
||||
|
||||
/// Filters the aggregated groups with a boolean SQL expression.
|
||||
@@ -1233,9 +1233,9 @@ extension AggregatingRequest where Self: TypedRequest, Self.RowDecoder: TableRec
|
||||
/// .having { max($0.score) > 1000 }
|
||||
/// ```
|
||||
public func having(
|
||||
_ predicate: (DatabaseComponents) -> any SQLExpressible
|
||||
) -> Self {
|
||||
having(predicate(Self.RowDecoder.databaseComponents))
|
||||
_ predicate: (DatabaseComponents) throws -> any SQLExpressible
|
||||
) rethrows -> Self {
|
||||
try having(predicate(Self.RowDecoder.databaseComponents))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1247,8 +1247,8 @@ extension AggregatingRequest where Self: TypedRequest, Self.RowDecoder: TableRec
|
||||
///
|
||||
/// ### The ORDER BY Clause
|
||||
///
|
||||
/// - ``order(_:)-54bt8``
|
||||
/// - ``order(_:)-7jcay``
|
||||
/// - ``order(_:)-5q7wj``
|
||||
/// - ``order(_:)-711zj``
|
||||
/// - ``order(literal:)``
|
||||
/// - ``order(sql:arguments:)``
|
||||
/// - ``orderWhenConnected(_:)``
|
||||
@@ -1454,9 +1454,9 @@ extension OrderedRequest where Self: TypedRequest, Self.RowDecoder: TableRecord
|
||||
/// .order(\.name)
|
||||
/// ```
|
||||
public func order(
|
||||
_ ordering: (DatabaseComponents) -> any SQLOrderingTerm
|
||||
) -> Self {
|
||||
order(ordering(Self.RowDecoder.databaseComponents))
|
||||
_ ordering: (DatabaseComponents) throws -> any SQLOrderingTerm
|
||||
) rethrows -> Self {
|
||||
try order(ordering(Self.RowDecoder.databaseComponents))
|
||||
}
|
||||
|
||||
/// Sorts the fetched rows according to the given SQL ordering terms.
|
||||
@@ -1485,9 +1485,9 @@ extension OrderedRequest where Self: TypedRequest, Self.RowDecoder: TableRecord
|
||||
/// .order { [$0.name] }
|
||||
/// ```
|
||||
public func order(
|
||||
_ orderings: (DatabaseComponents) -> [any SQLOrderingTerm]
|
||||
) -> Self {
|
||||
order(orderings(Self.RowDecoder.databaseComponents))
|
||||
_ orderings: (DatabaseComponents) throws -> [any SQLOrderingTerm]
|
||||
) rethrows -> Self {
|
||||
try order(orderings(Self.RowDecoder.databaseComponents))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1800,12 +1800,12 @@ extension JoinableRequest where Self: SelectionRequest {
|
||||
///
|
||||
/// ### The SELECT Clause
|
||||
///
|
||||
/// - ``SelectionRequest/annotated(with:)-56y26``
|
||||
/// - ``SelectionRequest/annotated(with:)-9nuwi``
|
||||
/// - ``SelectionRequest/annotated(with:)-9wodv``
|
||||
/// - ``SelectionRequest/annotated(with:)-69r3``
|
||||
/// - ``SelectionRequest/annotatedWhenConnected(with:)``
|
||||
/// - ``distinct()``
|
||||
/// - ``SelectionRequest/select(_:)-90gu2``
|
||||
/// - ``SelectionRequest/select(_:)-4iv1w``
|
||||
/// - ``SelectionRequest/select(_:)-270ge``
|
||||
/// - ``SelectionRequest/select(_:)-4jw13``
|
||||
/// - ``SelectionRequest/select(literal:)``
|
||||
/// - ``SelectionRequest/select(sql:arguments:)``
|
||||
/// - ``SelectionRequest/selectWhenConnected(_:)``
|
||||
@@ -1813,7 +1813,7 @@ extension JoinableRequest where Self: SelectionRequest {
|
||||
/// ### The WHERE Clause
|
||||
///
|
||||
/// - ``FilteredRequest/all()``
|
||||
/// - ``FilteredRequest/filter(_:)-5l0gu``
|
||||
/// - ``FilteredRequest/filter(_:)-7j0nw``
|
||||
/// - ``TableRequest/filter(id:)``
|
||||
/// - ``TableRequest/filter(ids:)``
|
||||
/// - ``TableRequest/filter(key:)-1p9sq``
|
||||
@@ -1829,21 +1829,21 @@ extension JoinableRequest where Self: SelectionRequest {
|
||||
///
|
||||
/// ### The GROUP BY and HAVING Clauses
|
||||
///
|
||||
/// - ``AggregatingRequest/group(_:)-9z116``
|
||||
/// - ``AggregatingRequest/group(_:)-43p07``
|
||||
/// - ``AggregatingRequest/group(_:)-5soxm``
|
||||
/// - ``AggregatingRequest/group(_:)-32exm``
|
||||
/// - ``AggregatingRequest/group(literal:)``
|
||||
/// - ``AggregatingRequest/group(sql:arguments:)``
|
||||
/// - ``TableRequest/groupByPrimaryKey()``
|
||||
/// - ``AggregatingRequest/groupWhenConnected(_:)``
|
||||
/// - ``AggregatingRequest/having(_:)-6zfvb``
|
||||
/// - ``AggregatingRequest/having(_:)-27hlo``
|
||||
/// - ``AggregatingRequest/having(literal:)``
|
||||
/// - ``AggregatingRequest/having(sql:arguments:)``
|
||||
/// - ``AggregatingRequest/havingWhenConnected(_:)``
|
||||
///
|
||||
/// ### The ORDER BY Clause
|
||||
///
|
||||
/// - ``OrderedRequest/order(_:)-54bt8``
|
||||
/// - ``OrderedRequest/order(_:)-7jcay``
|
||||
/// - ``OrderedRequest/order(_:)-5q7wj``
|
||||
/// - ``OrderedRequest/order(_:)-711zj``
|
||||
/// - ``OrderedRequest/order(literal:)``
|
||||
/// - ``OrderedRequest/order(sql:arguments:)``
|
||||
/// - ``OrderedRequest/orderWhenConnected(_:)``
|
||||
|
||||
@@ -1932,8 +1932,8 @@ extension Table {
|
||||
public func updateAll(
|
||||
_ db: Database,
|
||||
onConflict conflictResolution: Database.ConflictResolution? = nil,
|
||||
assignment: (DatabaseComponents) -> ColumnAssignment)
|
||||
throws -> Int
|
||||
assignment: (DatabaseComponents) throws -> ColumnAssignment
|
||||
) throws -> Int
|
||||
where RowDecoder: TableRecord
|
||||
{
|
||||
try updateAll(db, onConflict: conflictResolution, [assignment(RowDecoder.databaseComponents)])
|
||||
@@ -1968,8 +1968,8 @@ extension Table {
|
||||
public func updateAll(
|
||||
_ db: Database,
|
||||
onConflict conflictResolution: Database.ConflictResolution? = nil,
|
||||
assignments: (DatabaseComponents) -> [ColumnAssignment])
|
||||
throws -> Int
|
||||
assignments: (DatabaseComponents) throws -> [ColumnAssignment]
|
||||
) throws -> Int
|
||||
where RowDecoder: TableRecord
|
||||
{
|
||||
try updateAll(db, onConflict: conflictResolution, assignments(RowDecoder.databaseComponents))
|
||||
|
||||
@@ -78,9 +78,9 @@ extension TableRecord {
|
||||
/// let request = Player.select(\.score)
|
||||
/// ```
|
||||
public static func select(
|
||||
_ selection: (DatabaseComponents) -> any SQLSelectable
|
||||
) -> QueryInterfaceRequest<Self> {
|
||||
all().select(selection)
|
||||
_ selection: (DatabaseComponents) throws -> any SQLSelectable
|
||||
) rethrows -> QueryInterfaceRequest<Self> {
|
||||
try all().select(selection)
|
||||
}
|
||||
|
||||
/// Returns a request that selects the provided result columns.
|
||||
@@ -94,9 +94,9 @@ extension TableRecord {
|
||||
/// let request = Player.select { [$0.id, $0.score] }
|
||||
/// ```
|
||||
public static func select(
|
||||
_ selection: (DatabaseComponents) -> [any SQLSelectable]
|
||||
) -> QueryInterfaceRequest<Self> {
|
||||
all().select(selection)
|
||||
_ selection: (DatabaseComponents) throws -> [any SQLSelectable]
|
||||
) rethrows -> QueryInterfaceRequest<Self> {
|
||||
try all().select(selection)
|
||||
}
|
||||
|
||||
/// Returns a request that selects the provided SQL string.
|
||||
@@ -217,11 +217,11 @@ extension TableRecord {
|
||||
/// let maxScore = try request.fetchOne(db) // Int?
|
||||
/// ```
|
||||
public static func select<RowDecoder>(
|
||||
_ selection: (DatabaseComponents) -> any SQLSelectable,
|
||||
as type: RowDecoder.Type = RowDecoder.self)
|
||||
-> QueryInterfaceRequest<RowDecoder>
|
||||
_ selection: (DatabaseComponents) throws -> any SQLSelectable,
|
||||
as type: RowDecoder.Type = RowDecoder.self
|
||||
) rethrows -> QueryInterfaceRequest<RowDecoder>
|
||||
{
|
||||
all().select(selection, as: type)
|
||||
try all().select(selection, as: type)
|
||||
}
|
||||
|
||||
/// Returns a request that selects the provided SQL string, and defines the
|
||||
@@ -395,9 +395,9 @@ extension TableRecord {
|
||||
/// let request = Player.annotated { ($0.score + $0.bonus).forKey("totalScore") }
|
||||
/// ```
|
||||
public static func annotated(
|
||||
with selection: (DatabaseComponents) -> any SQLSelectable
|
||||
) -> QueryInterfaceRequest<Self> {
|
||||
all().annotated(with: selection)
|
||||
with selection: (DatabaseComponents) throws -> any SQLSelectable
|
||||
) rethrows -> QueryInterfaceRequest<Self> {
|
||||
try all().annotated(with: selection)
|
||||
}
|
||||
|
||||
/// Returns a request with the provided result columns appended to the
|
||||
@@ -415,9 +415,9 @@ extension TableRecord {
|
||||
/// let request = Player.annotated { [($0.score + $0.bonus).forKey("totalScore")] }
|
||||
/// ```
|
||||
public static func annotated(
|
||||
with selection: (DatabaseComponents) -> [any SQLSelectable]
|
||||
) -> QueryInterfaceRequest<Self> {
|
||||
all().annotated(with: selection)
|
||||
with selection: (DatabaseComponents) throws -> [any SQLSelectable]
|
||||
) rethrows -> QueryInterfaceRequest<Self> {
|
||||
try all().annotated(with: selection)
|
||||
}
|
||||
|
||||
// Accept SQLSpecificExpressible instead of SQLExpressible, so that we
|
||||
@@ -453,9 +453,9 @@ extension TableRecord {
|
||||
/// let request = Player.filter { $0.name == name }
|
||||
/// ```
|
||||
public static func filter(
|
||||
_ predicate: (DatabaseComponents) -> any SQLSpecificExpressible
|
||||
) -> QueryInterfaceRequest<Self> {
|
||||
all().filter(predicate)
|
||||
_ predicate: (DatabaseComponents) throws -> any SQLSpecificExpressible
|
||||
) rethrows -> QueryInterfaceRequest<Self> {
|
||||
try all().filter(predicate)
|
||||
}
|
||||
|
||||
/// Returns a request filtered by primary key.
|
||||
@@ -632,9 +632,9 @@ extension TableRecord {
|
||||
/// let request = Player.order(\.score.desc)
|
||||
/// ```
|
||||
public static func order(
|
||||
_ orderings: (DatabaseComponents) -> any SQLOrderingTerm
|
||||
) -> QueryInterfaceRequest<Self> {
|
||||
all().order(orderings)
|
||||
_ orderings: (DatabaseComponents) throws -> any SQLOrderingTerm
|
||||
) rethrows -> QueryInterfaceRequest<Self> {
|
||||
try all().order(orderings)
|
||||
}
|
||||
|
||||
/// Returns a request sorted according to the given SQL ordering terms.
|
||||
@@ -648,9 +648,9 @@ extension TableRecord {
|
||||
/// let request = Player.order { [$0.score.desc, $0.name] }
|
||||
/// ```
|
||||
public static func order(
|
||||
_ orderings: (DatabaseComponents) -> [any SQLOrderingTerm]
|
||||
) -> QueryInterfaceRequest<Self> {
|
||||
all().order(orderings)
|
||||
_ orderings: (DatabaseComponents) throws -> [any SQLOrderingTerm]
|
||||
) rethrows -> QueryInterfaceRequest<Self> {
|
||||
try all().order(orderings)
|
||||
}
|
||||
|
||||
/// Returns a request sorted by primary key.
|
||||
|
||||
@@ -329,8 +329,8 @@ extension MutablePersistableRecord {
|
||||
_ db: Database,
|
||||
onConflict conflictResolution: Database.ConflictResolution? = nil,
|
||||
fetch: (Statement) throws -> T,
|
||||
select: (DatabaseComponents) -> [any SQLSelectable])
|
||||
throws -> T
|
||||
select: (DatabaseComponents) throws -> [any SQLSelectable]
|
||||
) throws -> T
|
||||
where Self: TableRecord
|
||||
{
|
||||
try insertAndFetch(db, onConflict: conflictResolution, selection: select(Self.databaseComponents), fetch: fetch)
|
||||
@@ -578,8 +578,8 @@ extension MutablePersistableRecord {
|
||||
_ db: Database,
|
||||
onConflict conflictResolution: Database.ConflictResolution? = nil,
|
||||
fetch: (Statement) throws -> T,
|
||||
select: (DatabaseComponents) -> [any SQLSelectable])
|
||||
throws -> T
|
||||
select: (DatabaseComponents) throws -> [any SQLSelectable]
|
||||
) throws -> T
|
||||
where Self: TableRecord
|
||||
{
|
||||
try insertAndFetch(
|
||||
|
||||
@@ -261,8 +261,8 @@ extension PersistableRecord {
|
||||
_ db: Database,
|
||||
onConflict conflictResolution: Database.ConflictResolution? = nil,
|
||||
fetch: (Statement) throws -> T,
|
||||
select: (DatabaseComponents) -> [any SQLSelectable])
|
||||
throws -> T
|
||||
select: (DatabaseComponents) throws -> [any SQLSelectable]
|
||||
) throws -> T
|
||||
where Self: TableRecord
|
||||
{
|
||||
try insertAndFetch(db, onConflict: conflictResolution, selection: select(Self.databaseComponents), fetch: fetch)
|
||||
@@ -476,8 +476,8 @@ extension PersistableRecord {
|
||||
_ db: Database,
|
||||
onConflict conflictResolution: Database.ConflictResolution? = nil,
|
||||
fetch: (Statement) throws -> T,
|
||||
select: (DatabaseComponents) -> [any SQLSelectable])
|
||||
throws -> T
|
||||
select: (DatabaseComponents) throws -> [any SQLSelectable]
|
||||
) throws -> T
|
||||
where Self: TableRecord
|
||||
{
|
||||
try insertAndFetch(
|
||||
|
||||
@@ -61,11 +61,11 @@ import Foundation
|
||||
/// - ``all()``
|
||||
/// - ``annotated(with:)-4xoen``
|
||||
/// - ``annotated(with:)-8ce7u``
|
||||
/// - ``annotated(with:)-9qvhi``
|
||||
/// - ``annotated(with:)-12q5i``
|
||||
/// - ``annotated(with:)-58am5``
|
||||
/// - ``annotated(with:)-12jwq``
|
||||
/// - ``annotated(withOptional:)``
|
||||
/// - ``annotated(withRequired:)``
|
||||
/// - ``filter(_:)-2l1zl``
|
||||
/// - ``filter(_:)-4xvdh``
|
||||
/// - ``filter(id:)``
|
||||
/// - ``filter(ids:)``
|
||||
/// - ``filter(key:)-9ey53``
|
||||
@@ -84,15 +84,15 @@ import Foundation
|
||||
/// - ``matching(_:)-22m4o``
|
||||
/// - ``matching(_:)-1t8ph``
|
||||
/// - ``none()``
|
||||
/// - ``order(_:)-4h1zh``
|
||||
/// - ``order(_:)-21efu``
|
||||
/// - ``order(_:)-4j3ej``
|
||||
/// - ``order(_:)-53dja``
|
||||
/// - ``order(literal:)``
|
||||
/// - ``order(sql:arguments:)``
|
||||
/// - ``orderByPrimaryKey()``
|
||||
/// - ``request(for:)``
|
||||
/// - ``select(_:)-8pytw``
|
||||
/// - ``select(_:)-3aslb``
|
||||
/// - ``select(_:as:)-9s48t``
|
||||
/// - ``select(_:)-1bgd1``
|
||||
/// - ``select(_:)-8yqls``
|
||||
/// - ``select(_:as:)-7zz91``
|
||||
/// - ``select(literal:)``
|
||||
/// - ``select(literal:as:)``
|
||||
/// - ``select(sql:arguments:)``
|
||||
@@ -783,9 +783,8 @@ extension TableRecord {
|
||||
public static func updateAll(
|
||||
_ db: Database,
|
||||
onConflict conflictResolution: Database.ConflictResolution? = nil,
|
||||
assignments: (DatabaseComponents) -> [ColumnAssignment])
|
||||
throws -> Int
|
||||
{
|
||||
assignments: (DatabaseComponents) throws -> [ColumnAssignment]
|
||||
) throws -> Int {
|
||||
try updateAll(db, onConflict: conflictResolution, assignments(databaseComponents))
|
||||
}
|
||||
|
||||
@@ -816,9 +815,8 @@ extension TableRecord {
|
||||
public static func updateAll(
|
||||
_ db: Database,
|
||||
onConflict conflictResolution: Database.ConflictResolution? = nil,
|
||||
assignment: (DatabaseComponents) -> ColumnAssignment)
|
||||
throws -> Int
|
||||
{
|
||||
assignment: (DatabaseComponents) throws -> ColumnAssignment
|
||||
) throws -> Int {
|
||||
try updateAll(db, onConflict: conflictResolution, [assignment(databaseComponents)])
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user