1
1
import Foundation
2
2
import StructuredQueriesCore
3
3
4
+ // NB: Deprecated after 0.22.2:
5
+
6
+ extension Table {
7
+ @available (
8
+ * ,
9
+ deprecated,
10
+ message: " Prefer 'createTemporaryTrigger(after: .update(touch:))', instead "
11
+ )
12
+ public static func createTemporaryTrigger(
13
+ _ name: String ? = nil ,
14
+ ifNotExists: Bool = false ,
15
+ afterUpdateTouch updates: ( inout Updates < Self > ) -> Void ,
16
+ fileID: StaticString = #fileID,
17
+ line: UInt = #line,
18
+ column: UInt = #column
19
+ ) -> TemporaryTrigger < Self > {
20
+ Self . createTemporaryTrigger (
21
+ name,
22
+ ifNotExists: ifNotExists,
23
+ after: . update { _, new in
24
+ Self
25
+ . where { $0. rowid. eq ( new. rowid) }
26
+ . update { updates ( & $0) }
27
+ } ,
28
+ fileID: fileID,
29
+ line: line,
30
+ column: column
31
+ )
32
+ }
33
+
34
+ @available (
35
+ * ,
36
+ deprecated,
37
+ message: " Prefer 'createTemporaryTrigger(after: .update(touch:))', instead "
38
+ )
39
+ public static func createTemporaryTrigger< D: _OptionalPromotable < Date ? > > (
40
+ _ name: String ? = nil ,
41
+ ifNotExists: Bool = false ,
42
+ afterUpdateTouch dateColumn: KeyPath < TableColumns , TableColumn < Self , D > > ,
43
+ date dateFunction: any QueryExpression < D > = SQLQueryExpression < D > ( " datetime('subsec') " ) ,
44
+ fileID: StaticString = #fileID,
45
+ line: UInt = #line,
46
+ column: UInt = #column
47
+ ) -> TemporaryTrigger < Self > {
48
+ Self . createTemporaryTrigger (
49
+ name,
50
+ ifNotExists: ifNotExists,
51
+ afterUpdateTouch: {
52
+ $0 [ dynamicMember: dateColumn] = dateFunction
53
+ } ,
54
+ fileID: fileID,
55
+ line: line,
56
+ column: column
57
+ )
58
+ }
59
+
60
+ @available (
61
+ * ,
62
+ deprecated,
63
+ message: " Prefer 'createTemporaryTrigger(after: .insert(touch:))', instead "
64
+ )
65
+ public static func createTemporaryTrigger(
66
+ _ name: String ? = nil ,
67
+ ifNotExists: Bool = false ,
68
+ afterInsertTouch updates: ( inout Updates < Self > ) -> Void ,
69
+ fileID: StaticString = #fileID,
70
+ line: UInt = #line,
71
+ column: UInt = #column
72
+ ) -> TemporaryTrigger < Self > {
73
+ Self . createTemporaryTrigger (
74
+ name,
75
+ ifNotExists: ifNotExists,
76
+ after: . insert { new in
77
+ Self
78
+ . where { $0. rowid. eq ( new. rowid) }
79
+ . update { updates ( & $0) }
80
+ } ,
81
+ fileID: fileID,
82
+ line: line,
83
+ column: column
84
+ )
85
+ }
86
+
87
+ @available (
88
+ * ,
89
+ deprecated,
90
+ message: " Prefer 'createTemporaryTrigger(after: .insert(touch:))', instead "
91
+ )
92
+ public static func createTemporaryTrigger< D: _OptionalPromotable < Date ? > > (
93
+ _ name: String ? = nil ,
94
+ ifNotExists: Bool = false ,
95
+ afterInsertTouch dateColumn: KeyPath < TableColumns , TableColumn < Self , D > > ,
96
+ date dateFunction: any QueryExpression < D > = SQLQueryExpression < D > ( " datetime('subsec') " ) ,
97
+ fileID: StaticString = #fileID,
98
+ line: UInt = #line,
99
+ column: UInt = #column
100
+ ) -> TemporaryTrigger < Self > {
101
+ Self . createTemporaryTrigger (
102
+ name,
103
+ ifNotExists: ifNotExists,
104
+ afterInsertTouch: {
105
+ $0 [ dynamicMember: dateColumn] = dateFunction
106
+ } ,
107
+ fileID: fileID,
108
+ line: line,
109
+ column: column
110
+ )
111
+ }
112
+ }
113
+
4
114
// NB: Deprecated after 0.5.1:
5
115
6
116
extension Table {
7
117
@available (
8
- * , deprecated, message: " Use a trailing closure, instead: 'Table.insert { row }' "
118
+ * ,
119
+ deprecated,
120
+ message: " Use a trailing closure, instead: 'Table.insert { row }' "
9
121
)
10
122
public static func insert(
11
123
or conflictResolution: ConflictResolution ,
@@ -16,7 +128,9 @@ extension Table {
16
128
}
17
129
18
130
@available (
19
- * , deprecated, message: " Use a trailing closure, instead: 'Table.insert { rows }' "
131
+ * ,
132
+ deprecated,
133
+ message: " Use a trailing closure, instead: 'Table.insert { rows }' "
20
134
)
21
135
public static func insert(
22
136
or conflictResolution: ConflictResolution ,
@@ -49,7 +163,10 @@ extension Table {
49
163
50
164
@available ( * , deprecated, renamed: " insert(or:_:select:onConflictDoUpdate:) " )
51
165
public static func insert<
52
- V1, each V2 , From, Joins
166
+ V1,
167
+ each V2 ,
168
+ From,
169
+ Joins
53
170
> (
54
171
or conflictResolution: ConflictResolution ,
55
172
_ columns: ( TableColumns ) -> ( TableColumn < Self , V1 > , repeat TableColumn < Self , each V2 > ) ,
@@ -62,7 +179,9 @@ extension Table {
62
179
63
180
extension PrimaryKeyedTable {
64
181
@available (
65
- * , deprecated, message: " Use a trailing closure, instead: 'Table.insert { draft }' "
182
+ * ,
183
+ deprecated,
184
+ message: " Use a trailing closure, instead: 'Table.insert { draft }' "
66
185
)
67
186
public static func insert(
68
187
or conflictResolution: ConflictResolution ,
@@ -73,7 +192,9 @@ extension PrimaryKeyedTable {
73
192
}
74
193
75
194
@available (
76
- * , deprecated, message: " Use a trailing closure, instead: 'Table.insert { drafts }' "
195
+ * ,
196
+ deprecated,
197
+ message: " Use a trailing closure, instead: 'Table.insert { drafts }' "
77
198
)
78
199
public static func insert(
79
200
or conflictResolution: ConflictResolution ,
@@ -84,7 +205,9 @@ extension PrimaryKeyedTable {
84
205
}
85
206
86
207
@available (
87
- * , deprecated, message: " Use a trailing closure, instead: 'Table.upsert { draft }' "
208
+ * ,
209
+ deprecated,
210
+ message: " Use a trailing closure, instead: 'Table.upsert { draft }' "
88
211
)
89
212
public static func upsert(
90
213
or conflictResolution: ConflictResolution ,
0 commit comments