@@ -31,7 +31,7 @@ class Schema {
31
31
///
32
32
/// These options are enabled by passing them to a non-local [Table]
33
33
/// constructor.
34
- final class IncludeOldOptions {
34
+ final class TrackPreviousValuesOptions {
35
35
/// A filter of column names for which updates should be tracked.
36
36
///
37
37
/// When set to a non-null value, columns not included in this list will not
@@ -42,7 +42,8 @@ final class IncludeOldOptions {
42
42
/// instead of always including all old values.
43
43
final bool onlyWhenChanged;
44
44
45
- const IncludeOldOptions ({this .columnFilter, this .onlyWhenChanged = false });
45
+ const TrackPreviousValuesOptions (
46
+ {this .columnFilter, this .onlyWhenChanged = false });
46
47
}
47
48
48
49
/// A single table in the schema.
@@ -61,12 +62,12 @@ class Table {
61
62
/// Whether to add a hidden `_metadata` column that will be enabled for
62
63
/// updates to attach custom information about writes that will be reported
63
64
/// through [CrudEntry.metadata] .
64
- final bool includeMetadata ;
65
+ final bool trackMetadata ;
65
66
66
67
/// Whether to track old values of columns for [CrudEntry.oldData] .
67
68
///
68
- /// See [IncludeOldOptions ] for details.
69
- final IncludeOldOptions ? includeOld ;
69
+ /// See [TrackPreviousValuesOptions ] for details.
70
+ final TrackPreviousValuesOptions ? trackPreviousValues ;
70
71
71
72
/// Whether the table only exists locally.
72
73
final bool localOnly;
@@ -76,7 +77,7 @@ class Table {
76
77
77
78
/// Whether an `UPDATE` statement that doesn't change any values should be
78
79
/// ignored when creating CRUD entries.
79
- final bool ignoreEmptyUpdate ;
80
+ final bool ignoreEmptyUpdates ;
80
81
81
82
/// Override the name for the view
82
83
final String ? _viewNameOverride;
@@ -107,9 +108,9 @@ class Table {
107
108
this .indexes = const [],
108
109
String ? viewName,
109
110
this .localOnly = false ,
110
- this .ignoreEmptyUpdate = false ,
111
- this .includeMetadata = false ,
112
- this .includeOld ,
111
+ this .ignoreEmptyUpdates = false ,
112
+ this .trackMetadata = false ,
113
+ this .trackPreviousValues ,
113
114
}) : insertOnly = false ,
114
115
_viewNameOverride = viewName;
115
116
@@ -120,9 +121,9 @@ class Table {
120
121
{this .indexes = const [], String ? viewName})
121
122
: localOnly = true ,
122
123
insertOnly = false ,
123
- includeMetadata = false ,
124
- includeOld = null ,
125
- ignoreEmptyUpdate = false ,
124
+ trackMetadata = false ,
125
+ trackPreviousValues = null ,
126
+ ignoreEmptyUpdates = false ,
126
127
_viewNameOverride = viewName;
127
128
128
129
/// Create a table that only supports inserts.
@@ -137,9 +138,9 @@ class Table {
137
138
this .name,
138
139
this .columns, {
139
140
String ? viewName,
140
- this .ignoreEmptyUpdate = false ,
141
- this .includeMetadata = false ,
142
- this .includeOld ,
141
+ this .ignoreEmptyUpdates = false ,
142
+ this .trackMetadata = false ,
143
+ this .trackPreviousValues ,
143
144
}) : localOnly = false ,
144
145
insertOnly = true ,
145
146
indexes = const [],
@@ -172,11 +173,11 @@ class Table {
172
173
"Invalid characters in view name: $_viewNameOverride " );
173
174
}
174
175
175
- if (includeMetadata && localOnly) {
176
+ if (trackMetadata && localOnly) {
176
177
throw AssertionError ("Local-only tables can't track metadata" );
177
178
}
178
179
179
- if (includeOld != null && localOnly) {
180
+ if (trackPreviousValues != null && localOnly) {
180
181
throw AssertionError ("Local-only tables can't track old values" );
181
182
}
182
183
@@ -228,11 +229,11 @@ class Table {
228
229
'insert_only' : insertOnly,
229
230
'columns' : columns,
230
231
'indexes' : indexes.map ((e) => e.toJson (this )).toList (growable: false ),
231
- 'ignore_empty_update' : ignoreEmptyUpdate ,
232
- 'include_metadata' : includeMetadata ,
233
- if (includeOld case final includeOld ? ) ...{
234
- 'include_old' : includeOld .columnFilter ?? true ,
235
- 'include_old_only_when_changed' : includeOld .onlyWhenChanged,
232
+ 'ignore_empty_update' : ignoreEmptyUpdates ,
233
+ 'include_metadata' : trackMetadata ,
234
+ if (trackPreviousValues case final trackPreviousValues ? ) ...{
235
+ 'include_old' : trackPreviousValues .columnFilter ?? true ,
236
+ 'include_old_only_when_changed' : trackPreviousValues .onlyWhenChanged,
236
237
},
237
238
};
238
239
}
0 commit comments