From c1ae47d188b249aa2dda161b345798db4d53fd48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Thu, 22 Feb 2018 23:26:37 +0100 Subject: [PATCH] Splitting rows: documentation WIP --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ed317cdb5..c261077ad 100644 --- a/README.md +++ b/README.md @@ -4587,7 +4587,7 @@ This technique works pretty well, but it has three drawbacks: 2. Such queries are difficult to write by hand. 3. The mangled names are a *very* bad fit for [RowConvertible](#rowconvertible-protocol) records that expect specific column names. After all, if the `Team` record type can read `SELECT * FROM teams ...`, it should be able to read `SELECT ..., teams.*, ...` as well. -We thus need another technique. Below we'll see how to split rows into slices, and preserve column names. +We thus need another technique. **Below we'll see how to split rows into slices, and preserve column names.** `SELECT players.*, teams.*, MAX(rounds.score) AS maxScore FROM ...` will be splitted into three slices: one that contains player's columns, one that contains team's columns, and a remaining slice that contains remaining column(s). The Player record type will be able to read the first slice, which contains the colums expected by the `Player.init(row:)` initializer. In the same way, the Team record type could read the second slice. @@ -4601,10 +4601,10 @@ Unlike the name-mangling technique, splitting rows keeps SQL legible, accepts yo ### Splitting Rows, an Introduction -To split rows, we will use [row adapters](#row-adapters). Row adapters adapt rows so that row consumers see exactly the columns they want. Among other things, row adapters can define several *row scopes* that give access to as many *row slices*. Sounds like a perfect match. - Let's first write some introductory code, hoping that this chapter will make you understand how pieces fall together. We'll see [later](#splitting-rows-the-record-way) how records will help us streamline the initial approach, how to track changes in joined requests, and how we can use the standard Decodable protocol. +To split rows, we will use [row adapters](#row-adapters). Row adapters adapt rows so that row consumers see exactly the columns they want. Among other things, row adapters can define several *row scopes* that give access to as many *row slices*. Sounds like a perfect match. + At the very beginning, there is an SQL query: ```swift