Skip to content

Commit bc6f0df

Browse files
authored
Update docs (#148)
- Stub an article for full-text search - Fix outdated DocC symbols - Miscellaneous fixes One breaking change: `jsonGroupArray`'s `isDistinct` parameter was renamed to `distinct`. Applying fix-it should be enough to migrate and we're pre-1.0, so not sure a deprecated overload is worth it.
1 parent 6ee63c9 commit bc6f0df

File tree

10 files changed

+48
-23
lines changed

10 files changed

+48
-23
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Full-text search
2+
3+
## Overview
4+
5+
StructuredQueries comes with built-in support for SQLite's FTS5 module.
6+
7+
## Topics
8+
9+
### Virtual tables
10+
11+
- ``FTS5``
12+
13+
### Performing searches
14+
15+
- ``TableDefinition/match(_:)``
16+
- ``TableColumnExpression/match(_:)``
17+
18+
### Ranking searches
19+
20+
- ``TableDefinition/rank``
21+
- ``TableDefinition/bm25(_:)``
22+
23+
### Highlighting results
24+
25+
- ``TableColumnExpression/highlight(_:_:)``
26+
- ``TableColumnExpression/snippet(_:_:_:_:)``

Sources/StructuredQueriesCore/Documentation.docc/Articles/InsertStatements.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -411,8 +411,7 @@ Or you can conditionally upsert from given indexed columns using `onConflict:doU
411411
}
412412
}
413413

414-
Upsert clauses have an additional, special ``Updates/excluded`` qualifier for referring to a row
415-
that failed to insert.
414+
Upsert clauses have an additional, special argument for referring to a row that failed to insert.
416415

417416
```swift
418417
@Row {
@@ -425,8 +424,8 @@ that failed to insert.
425424
} onConflict: {
426425
$0.title
427426
} doUpdate: {
428-
$0.isCompleted = $0.excluded.isCompleted
429-
$0.priority = $0.excluded.priority
427+
$0.isCompleted = $1.isCompleted
428+
$0.priority = $1.priority
430429
}
431430
```
432431
}
@@ -460,7 +459,6 @@ that failed to insert.
460459

461460
### Inserting drafts
462461

463-
- ``PrimaryKeyedTable/insert(or:_:values:onConflictDoUpdate:where:)``
464462
- ``PrimaryKeyedTable/upsert(or:values:)``
465463

466464
### Inserting from a select

Sources/StructuredQueriesCore/Documentation.docc/Articles/Operators.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ Explore the full list of operators below.
116116
- ``QueryExpression/+(_:_:)``
117117
- ``QueryExpression/like(_:escape:)``
118118
- ``QueryExpression/glob(_:)``
119-
- ``QueryExpression/match(_:)``
120119
- ``QueryExpression/hasPrefix(_:)``
121120
- ``QueryExpression/hasSuffix(_:)``
122121
- ``QueryExpression/contains(_:)``
@@ -128,7 +127,7 @@ Explore the full list of operators below.
128127

129128
- ``QueryExpression/in(_:)``
130129
- ``Statement/contains(_:)``
131-
- ``Statement/exists()``
130+
- ``PartialSelectStatement/exists()``
132131
- ``Swift/Array``
133132
- ``Swift/ClosedRange``
134133

Sources/StructuredQueriesCore/Documentation.docc/Articles/QueryCookbook.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ extension Reminder.TableColumns {
133133
```
134134
135135
Then you can use these helpers when building a query. For example, you can use
136-
``PrimaryKeyedTableDefinition/count(filter:)`` to count the number of past due, current and
136+
``PrimaryKeyedTableDefinition/count(distinct:filter:)`` to count the number of past due, current and
137137
scheduled reminders in one single query like so:
138138

139139
@Row {
@@ -409,8 +409,8 @@ struct Row {
409409
410410
This allows the query to serialize the associated rows into JSON, which are then deserialized into
411411
a `Row` type. To construct such a query you can use the
412-
``PrimaryKeyedTableDefinition/jsonGroupArray(order:filter:)`` property that is defined on the
413-
columns of [primary keyed tables](<doc:PrimaryKeyedTables>):
412+
``PrimaryKeyedTableDefinition/jsonGroupArray(distinct:order:filter:)`` property that is defined on
413+
the columns of [primary keyed tables](<doc:PrimaryKeyedTables>):
414414

415415
```swift
416416
RemindersList
@@ -471,8 +471,8 @@ RemindersList
471471
.select {
472472
Row.Columns(
473473
remindersList: $0,
474-
milestones: $1.jsonGroupArray(isDistinct: true),
475-
reminders: $2.jsonGroupArray(isDistinct: true)
474+
milestones: $1.jsonGroupArray(distinct: true),
475+
reminders: $2.jsonGroupArray(distinct: true)
476476
)
477477
}
478478
```

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,6 @@ Reminder.delete(reminder)
134134

135135
- ``Draft``
136136
- ``find(_:)``
137-
- ``insert(or:_:values:onConflict:where:doUpdate:where:)``
138-
- ``insert(or:_:values:onConflictDoUpdate:where:)``
139137
- ``update(or:_:)``
140138
- ``upsert(or:values:)``
141139
- ``delete(_:)``

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
### JSON functions
2828
2929
- ``jsonArrayLength()``
30-
- ``jsonGroupArray(order:filter:)``
31-
- ``jsonObject()``
30+
- ``jsonGroupArray(distinct:order:filter:)``
31+
- ``TableDefinition/jsonObject()``
3232
- ``jsonPatch(_:)``
3333
3434
### Optionality

Sources/StructuredQueriesCore/Documentation.docc/StructuredQueriesCore.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,4 +138,5 @@ reading to learn more about building SQL with StructuredQueries.
138138

139139
### Advanced
140140

141+
- <doc:FullTextSearch>
141142
- <doc:Integration>

Sources/StructuredQueriesCore/PrimaryKeyed.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,10 @@ extension TableDefinition where QueryValue: TableDraft {
6767
extension PrimaryKeyedTableDefinition {
6868
/// A query expression representing the number of rows in this table.
6969
///
70-
/// - Parameter filter: A `FILTER` clause to apply to the aggregation.
70+
/// - Parameters:
71+
/// - isDistinct: Whether or not to include a `DISTINCT` clause, which filters duplicates from
72+
/// the aggregation.
73+
/// - filter: A `FILTER` clause to apply to the aggregation.
7174
/// - Returns: An expression representing the number of rows in this table.
7275
public func count(
7376
distinct isDistinct: Bool = false,

Sources/StructuredQueriesCore/SQLite/JSONFunctions.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ extension QueryExpression where QueryValue: Codable & QueryBindable {
4242
/// - filter: A `FILTER` clause to apply to the aggregation.
4343
/// - Returns: A JSON array aggregate of this expression.
4444
public func jsonGroupArray(
45-
isDistinct: Bool = false,
45+
distinct isDistinct: Bool = false,
4646
order: (some QueryExpression)? = Bool?.none,
4747
filter: (some QueryExpression<Bool>)? = Bool?.none
4848
) -> some QueryExpression<[QueryValue].JSONRepresentation> {
@@ -108,7 +108,7 @@ extension PrimaryKeyedTableDefinition where QueryValue: Codable {
108108
/// - filter: A `FILTER` clause to apply to the aggregation.
109109
/// - Returns: A JSON array aggregate of this table.
110110
public func jsonGroupArray(
111-
isDistinct: Bool = false,
111+
distinct isDistinct: Bool = false,
112112
order: (some QueryExpression)? = Bool?.none,
113113
filter: (some QueryExpression<Bool>)? = Bool?.none
114114
) -> some QueryExpression<[QueryValue].JSONRepresentation> {
@@ -174,7 +174,7 @@ extension PrimaryKeyedTableDefinition where QueryValue: _OptionalProtocol & Coda
174174
/// - filter: A `FILTER` clause to apply to the aggregation.
175175
/// - Returns: A JSON array aggregate of this table.
176176
public func jsonGroupArray<Wrapped: Codable>(
177-
isDistinct: Bool = false,
177+
distinct isDistinct: Bool = false,
178178
order: (some QueryExpression)? = Bool?.none,
179179
filter: (some QueryExpression<Bool>)? = Bool?.none
180180
) -> some QueryExpression<[Wrapped].JSONRepresentation>

Tests/StructuredQueriesTests/JSONFunctionsTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ extension SnapshotTests {
4343
@Test func jsonGroupArrayDisctinct() {
4444
assertQuery(
4545
Reminder.select {
46-
$0.priority.jsonGroupArray(isDistinct: true)
46+
$0.priority.jsonGroupArray(distinct: true)
4747
}
4848
) {
4949
"""
@@ -221,8 +221,8 @@ extension SnapshotTests {
221221
.select {
222222
RemindersListRow.Columns(
223223
remindersList: $0,
224-
milestones: $1.jsonGroupArray(isDistinct: true),
225-
reminders: $2.jsonGroupArray(isDistinct: true)
224+
milestones: $1.jsonGroupArray(distinct: true),
225+
reminders: $2.jsonGroupArray(distinct: true)
226226
)
227227
}
228228
.limit(1)

0 commit comments

Comments
 (0)