@@ -24,10 +24,10 @@ private struct ReminderWithList {
2424```
2525
2626Note that we have applied both the ` @Table ` macro and ` @Selection ` macro. This is similar to what
27- one does with common table expressions, and it allows one to represent a type that for intents and
27+ one does with common table expressions, and it allows one to represent a type that for intents and
2828purposes seems like a regular SQLite table, but it's not actually persisted in the database.
2929
30- With that type defined we can use the
30+ With that type defined we can use the
3131`` StructuredQueriesCore/Table/createTemporaryView(ifNotExists:as:) `` to create a SQL query that
3232creates a temporary view. You provide a select statement that selects all the data needed for the
3333view:
@@ -46,27 +46,27 @@ ReminderWithList.createTemporaryView(
4646```
4747
4848Once that is executed in your database you are free to query from this table as if it is a regular
49- table:
49+ table:
5050
5151@Row {
5252 @Column {
5353 ```swift
5454 ReminderWithList
55- .order {
56- ($0.remindersListTitle,
57- $0.reminderTitle)
55+ .order {
56+ ($0.remindersListTitle,
57+ $0.reminderTitle)
5858 }
5959 .limit(3)
6060 ```
6161 }
6262 @Column {
6363 ```sql
64- SELECT
65- "reminderWithLists"."reminderTitle",
64+ SELECT
65+ "reminderWithLists"."reminderTitle",
6666 "reminderWithLists"."remindersListTitle"
6767 FROM "reminderWithLists"
68- ORDER BY
69- "reminderWithLists"."remindersListTitle",
68+ ORDER BY
69+ "reminderWithLists"."remindersListTitle",
7070 "reminderWithLists"."reminderTitle"
7171 LIMIT 3
7272 ```
@@ -85,12 +85,12 @@ example if you try to insert into `ReminderWithList` you will be met with a SQL
8585``` swift
8686ReminderWithList.insert {
8787 ReminderWithList (
88- reminderTitle : " Morning sync" ,
88+ reminderTitle : " Morning sync" ,
8989 remindersListTitle : " Business"
9090 )
9191}
9292// 🛑 cannot modify reminderWithLists because it is a view
93- ```
93+ ```
9494
9595However, it is possible to restore inserts if you can describe how inserting a ` (String, String) `
9696pair into the table ultimately re-routes to inserts into your actual, non-view tables. The logic
@@ -100,7 +100,7 @@ we could try first creating a new list with the title, and then use that new lis
100100reminder with the title. Or, we could decide that we will not allow creating a new list, and
101101instead we will just find an existing list with the title, and if we cannot then we fail the query.
102102
103- In order to demonstrate this technique, we will use the latter rerouting logic: when a
103+ In order to demonstrate this technique, we will use the latter rerouting logic: when a
104104` (String, String) ` is inserted into ` ReminderWithList ` we will only create a new reminder with
105105the title specified, and we will only find an existing reminders list (if one exists) for the title
106106specified. And to implement this rerouting logic, one uses a [ temporary trigger] ( < doc:Triggers > ) on
@@ -112,7 +112,7 @@ ReminderWithList.createTemporaryTrigger(
112112 insteadOf : .insert { new in
113113 Reminder.insert {
114114 (
115- $0 .title ,
115+ $0 .title ,
116116 $0 .remindersListID
117117 )
118118 } values : {
@@ -133,7 +133,7 @@ view:
133133``` swift
134134ReminderWithList.insert {
135135 ReminderWithList (
136- reminderTitle : " Morning sync" ,
136+ reminderTitle : " Morning sync" ,
137137 remindersListTitle : " Business"
138138 )
139139}
0 commit comments