Skip to content

Commit b600d52

Browse files
committed
Add QueryExpression.jsonPatch
Found use in a downstream project, so mainlining this.
1 parent efd928f commit b600d52

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

Sources/StructuredQueriesCore/Documentation.docc/Extensions/QueryExpression.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
2929
- ``jsonArrayLength()``
3030
- ``jsonGroupArray(order:filter:)``
31+
- ``jsonPatch(_:)``
3132
3233
### Optionality
3334

Sources/StructuredQueriesCore/SQLite/JSONFunctions.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@ import Foundation
22
import StructuredQueriesSupport
33

44
extension QueryExpression {
5+
/// Passes this expression and the given one to the `json_patch` function.
6+
///
7+
/// - Parameter other: A JSON object to patch this object with.
8+
/// - Returns: A JSON expression of the result of the invoking the `json_patch` function.
9+
public func jsonPatch<QueryOutput: Codable>(
10+
_ other: some QueryExpression<QueryValue>
11+
) -> some QueryExpression<QueryValue>
12+
where QueryValue == _CodableJSONRepresentation<QueryOutput> {
13+
QueryFunction("json_patch", self, other)
14+
}
15+
516
/// Wraps this expression with the `json_array_length` function.
617
///
718
/// ```swift

0 commit comments

Comments
 (0)