From a8f7978ec42c405e16f9e00ebc8e102a61ae63ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Sun, 26 Apr 2020 11:55:53 +0200 Subject: [PATCH] Update documention after d0ba9e342cba5c62874c37e4e11bd288bd92ebed --- Documentation/AssociationsBasics.md | 30 ++++++++++++++--------------- README.md | 6 +++--- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Documentation/AssociationsBasics.md b/Documentation/AssociationsBasics.md index d48e2a5d9..4fc7976e6 100644 --- a/Documentation/AssociationsBasics.md +++ b/Documentation/AssociationsBasics.md @@ -1830,7 +1830,7 @@ struct AuthorInfo: Decodable, FetchableRecord { } // SELECT author.*, -// COUNT(DISTINCT book.rowid) AS bookCount, +// COUNT(DISTINCT book.id) AS bookCount, // MAX(book.year) AS maxBookYear, // FROM author // LEFT JOIN book ON book.authorId = author.id @@ -1923,7 +1923,7 @@ The `having(_:)` method filters a request according to an aggregated value. You FROM author LEFT JOIN book ON book.authorId = author.id GROUP BY author.id - HAVING COUNT(DISTINCT book.rowid) = 0 + HAVING COUNT(DISTINCT book.id) = 0 ``` @@ -1942,7 +1942,7 @@ The `having(_:)` method filters a request according to an aggregated value. You FROM author LEFT JOIN book ON book.authorId = author.id GROUP BY author.id - HAVING COUNT(DISTINCT book.rowid) > 0 + HAVING COUNT(DISTINCT book.id) > 0 ``` @@ -1961,7 +1961,7 @@ The `having(_:)` method filters a request according to an aggregated value. You FROM author LEFT JOIN book ON book.authorId = author.id GROUP BY author.id - HAVING COUNT(DISTINCT book.rowid) >= 2 + HAVING COUNT(DISTINCT book.id) >= 2 ``` @@ -1999,7 +1999,7 @@ The `having(_:)` method filters a request according to an aggregated value. You FROM author LEFT JOIN book ON book.authorId = author.id AND book.kind = 'novel' GROUP BY author.id - HAVING COUNT(DISTINCT book.rowid) > 0 + HAVING COUNT(DISTINCT book.id) > 0 ``` @@ -2020,7 +2020,7 @@ The `having(_:)` method filters a request according to an aggregated value. You LEFT JOIN book ON book.authorId = author.id LEFT JOIN painting ON painting.authorId = author.id GROUP BY author.id - HAVING COUNT(DISTINCT book.rowid) > COUNT(DISTINCT painting.rowid) + HAVING COUNT(DISTINCT book.id) > COUNT(DISTINCT painting.id) ``` @@ -2040,7 +2040,7 @@ The `having(_:)` method filters a request according to an aggregated value. You LEFT JOIN book ON book.authorId = author.id LEFT JOIN painting ON painting.authorId = author.id GROUP BY author.id - HAVING ((COUNT(DISTINCT book.rowid) = 0) AND (COUNT(DISTINCT painting.rowid) > 0)) + HAVING ((COUNT(DISTINCT book.id) = 0) AND (COUNT(DISTINCT painting.id) > 0)) ``` @@ -2065,7 +2065,7 @@ Aggregates can be modified and combined with Swift operators: LEFT JOIN book ON book.authorId = author.id LEFT JOIN painting ON painting.authorId = author.id GROUP BY author.id - HAVING ((COUNT(DISTINCT book.rowid) = 0) AND (COUNT(DISTINCT painting.rowid) = 0)) + HAVING ((COUNT(DISTINCT book.id) = 0) AND (COUNT(DISTINCT painting.id) = 0)) ``` @@ -2101,8 +2101,8 @@ Aggregates can be modified and combined with Swift operators: ```sql SELECT author.*, - (COUNT(DISTINCT book.rowid) + - COUNT(DISTINCT painting.rowid)) AS workCount + (COUNT(DISTINCT book.id) + + COUNT(DISTINCT painting.id)) AS workCount FROM author LEFT JOIN book ON book.authorId = author.id LEFT JOIN painting ON painting.authorId = author.id @@ -2183,7 +2183,7 @@ In this other example, the `Author.books` and `Author.paintings` have the distin ```sql SELECT author.*, - (COUNT(DISTINCT book.rowid) + COUNT(DISTINCT painting.rowid)) AS workCount + (COUNT(DISTINCT book.id) + COUNT(DISTINCT painting.id)) AS workCount FROM author LEFT JOIN book ON book.authorId = author.id LEFT JOIN painting ON painting.authorId = author.id @@ -2218,8 +2218,8 @@ But in the following example, we use the same association `Author.books` twice, ```sql SELECT author.*, - COUNT(DISTINCT book1.rowid) AS novelCount, - COUNT(DISTINCT book2.rowid) AS theatrePlayCount + COUNT(DISTINCT book1.id) AS novelCount, + COUNT(DISTINCT book2.id) AS theatrePlayCount FROM author LEFT JOIN book book1 ON book1.authorId = author.id AND book1.kind = 'novel' LEFT JOIN book book2 ON book2.authorId = author.id AND book2.kind = 'theatrePlay' @@ -2258,8 +2258,8 @@ But in the following example, we use the same association `Author.books` twice, ```sql SELECT author.*, - COUNT(DISTINCT book.rowid) AS novelCount, - COUNT(DISTINCT book.rowid) AS theatrePlayCount + COUNT(DISTINCT book.id) AS novelCount, + COUNT(DISTINCT book.id) AS theatrePlayCount FROM author LEFT JOIN book ON book.authorId = author.id AND (book.kind = 'novel' AND book.kind = 'theatrePlay') diff --git a/README.md b/README.md index 44bd47991..034c74122 100644 --- a/README.md +++ b/README.md @@ -4010,7 +4010,7 @@ You can now build requests with the following methods: `all`, `none`, `select`, - `annotated(with: aggregate)` extends the selection with [association aggregates](Documentation/AssociationsBasics.md#association-aggregates). ```swift - // SELECT team.*, COUNT(DISTINCT player.rowid) AS playerCount + // SELECT team.*, COUNT(DISTINCT player.id) AS playerCount // FROM team // LEFT JOIN player ON player.teamId = team.id // GROUP BY team.id @@ -4086,7 +4086,7 @@ You can now build requests with the following methods: `all`, `none`, `select`, // FROM team // LEFT JOIN player ON player.teamId = team.id // GROUP BY team.id - // HAVING COUNT(DISTINCT player.rowid) >= 5 + // HAVING COUNT(DISTINCT player.id) >= 5 Team.having(Team.players.count >= 5) ``` @@ -6956,7 +6956,7 @@ This method blocks the current thread until all current database accesses are co [Data Protection](https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/StrategiesforImplementingYourApp/StrategiesforImplementingYourApp.html#//apple_ref/doc/uid/TP40007072-CH5-SW21) lets you protect files so that they are encrypted and unavailable until the device is unlocked. Data protection can be enabled [globally](https://developer.apple.com/library/content/documentation/IDEs/Conceptual/AppDistributionGuide/AddingCapabilities/AddingCapabilities.html#//apple_ref/doc/uid/TP40012582-CH26-SW30) for all files created by an application. - +g You can also explicitly protect a database, by configuring its enclosing *directory*. This will not only protect the database file, but also all [temporary files](https://www.sqlite.org/tempfiles.html) created by SQLite (including the persistent `.shm` and `.wal` files created by [database pools](#database-pools)). For example, to explicitly use [complete](https://developer.apple.com/reference/foundation/fileprotectiontype/1616200-complete) protection: