Skip to content

Commit 9982141

Browse files
authored
Revert "feat(datastore): Add ModelField ReadOnly support (#599)" (#994)
This reverts commit fd12602.
1 parent a6ca33c commit 9982141

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+323
-2093
lines changed

packages/amplify_datastore/android/src/main/kotlin/com/amazonaws/amplify/amplify_datastore/types/model/FlutterModelField.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ data class FlutterModelField(val map: Map<String, Any>) {
3939
// True if the field is an instance of model.
4040
private val isModel: Boolean = type.isModel();
4141

42-
private val isReadOnly: Boolean = map["isReadOnly"] as Boolean
43-
4442
// An array of rules for owner based authorization
4543
private val authRules: List<FlutterAuthRule>? =
4644
(map["authRules"] as List<Map<String, Any>>?)?.map { serializedAuthRule ->
@@ -66,7 +64,6 @@ data class FlutterModelField(val map: Map<String, Any>) {
6664
.isArray(isArray)
6765
.isEnum(isEnum)
6866
.isModel(isModel)
69-
.isReadOnly(isReadOnly)
7067

7168
if (!authRules.isNullOrEmpty()) {
7269
builder = builder.authRules(authRules.map { authRule ->

packages/amplify_datastore/android/src/test/kotlin/com/amazonaws/amplify/amplify_datastore/AmplifyDataStorePluginTest.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ class AmplifyDataStorePluginTest {
8585
"targetType" to "Blog",
8686
"isRequired" to false,
8787
"isArray" to false,
88-
"isReadOnly" to false,
8988
"type" to mapOf(
9089
"fieldType" to "string"
9190
)

packages/amplify_datastore/example/ios/unit_tests/resources/modelSchema/model_schema_maps.json

Lines changed: 21 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,15 @@
99
"fieldType": "string"
1010
},
1111
"isRequired": true,
12-
"isArray": false,
13-
"isReadOnly": false
12+
"isArray": false
1413
},
1514
"name": {
1615
"name": "name",
1716
"type": {
1817
"fieldType": "string"
1918
},
2019
"isRequired": true,
21-
"isArray": false,
22-
"isReadOnly": false
20+
"isArray": false
2321
},
2422
"posts": {
2523
"name": "posts",
@@ -29,7 +27,6 @@
2927
},
3028
"isRequired": false,
3129
"isArray": true,
32-
"isReadOnly": false,
3330
"association": {
3431
"associationType": "HasMany",
3532
"associatedName": "blog",
@@ -49,8 +46,7 @@
4946
"fieldType": "string"
5047
},
5148
"isRequired": true,
52-
"isArray": false,
53-
"isReadOnly": false
49+
"isArray": false
5450
},
5551
"post": {
5652
"name": "post",
@@ -60,7 +56,6 @@
6056
},
6157
"isRequired": false,
6258
"isArray": false,
63-
"isReadOnly": false,
6459
"association": {
6560
"associationType": "BelongsTo",
6661
"targetName": "postID"
@@ -72,8 +67,7 @@
7267
"fieldType": "string"
7368
},
7469
"isRequired": true,
75-
"isArray": false,
76-
"isReadOnly": false
70+
"isArray": false
7771
}
7872
}
7973
},
@@ -88,35 +82,31 @@
8882
"fieldType": "string"
8983
},
9084
"isRequired": true,
91-
"isArray": false,
92-
"isReadOnly": false
85+
"isArray": false
9386
},
9487
"title": {
9588
"name": "title",
9689
"type": {
9790
"fieldType": "string"
9891
},
9992
"isRequired": true,
100-
"isArray": false,
101-
"isReadOnly": false
93+
"isArray": false
10294
},
10395
"created": {
10496
"name": "created",
10597
"type": {
10698
"fieldType": "dateTime"
10799
},
108100
"isRequired": false,
109-
"isArray": false,
110-
"isReadOnly": false
101+
"isArray": false
111102
},
112103
"rating": {
113104
"name": "rating",
114105
"type": {
115106
"fieldType": "int"
116107
},
117108
"isRequired": false,
118-
"isArray": false,
119-
"isReadOnly": false
109+
"isArray": false
120110
},
121111
"blog": {
122112
"name": "blog",
@@ -126,7 +116,6 @@
126116
},
127117
"isRequired": false,
128118
"isArray": false,
129-
"isReadOnly": false,
130119
"association": {
131120
"associationType": "BelongsTo",
132121
"targetName": "blogID"
@@ -140,7 +129,6 @@
140129
},
141130
"isRequired": false,
142131
"isArray": true,
143-
"isReadOnly": false,
144132
"association": {
145133
"associationType": "HasMany",
146134
"associatedName": "post",
@@ -155,7 +143,6 @@
155143
},
156144
"isRequired": true,
157145
"isArray": false,
158-
"isReadOnly": false,
159146
"association": {
160147
"associationType": "BelongsTo",
161148
"targetName": "authorId"
@@ -182,26 +169,23 @@
182169
"fieldType": "string"
183170
},
184171
"isRequired": true,
185-
"isArray": false,
186-
"isReadOnly": false
172+
"isArray": false
187173
},
188174
"title": {
189175
"name": "title",
190176
"type": {
191177
"fieldType": "string"
192178
},
193179
"isRequired": true,
194-
"isArray": false,
195-
"isReadOnly": false
180+
"isArray": false
196181
},
197182
"owner": {
198183
"name": "owner",
199184
"type": {
200185
"fieldType": "string"
201186
},
202187
"isRequired": false,
203-
"isArray": false,
204-
"isReadOnly": false
188+
"isArray": false
205189
}
206190
}
207191
},
@@ -216,89 +200,79 @@
216200
"fieldType": "string"
217201
},
218202
"isRequired": true,
219-
"isArray": false,
220-
"isReadOnly": false
203+
"isArray": false
221204
},
222205
"stringType": {
223206
"name": "stringType",
224207
"type": {
225208
"fieldType": "string"
226209
},
227210
"isRequired": true,
228-
"isArray": false,
229-
"isReadOnly": false
211+
"isArray": false
230212
},
231213
"intType": {
232214
"name": "intType",
233215
"type": {
234216
"fieldType": "int"
235217
},
236218
"isRequired": true,
237-
"isArray": false,
238-
"isReadOnly": false
219+
"isArray": false
239220
},
240221
"floatType": {
241222
"name": "floatType",
242223
"type": {
243224
"fieldType": "double"
244225
},
245226
"isRequired": true,
246-
"isArray": false,
247-
"isReadOnly": false
227+
"isArray": false
248228
},
249229
"boolType": {
250230
"name": "boolType",
251231
"type": {
252232
"fieldType": "bool"
253233
},
254234
"isRequired": true,
255-
"isArray": false,
256-
"isReadOnly": false
235+
"isArray": false
257236
},
258237
"dateType": {
259238
"name": "dateType",
260239
"type": {
261240
"fieldType": "date"
262241
},
263242
"isRequired": true,
264-
"isArray": false,
265-
"isReadOnly": false
243+
"isArray": false
266244
},
267245
"dateTimeType": {
268246
"name": "dateTimeType",
269247
"type": {
270248
"fieldType": "dateTime"
271249
},
272250
"isRequired": true,
273-
"isArray": false,
274-
"isReadOnly": false
251+
"isArray": false
275252
},
276253
"timeType": {
277254
"name": "timeType",
278255
"type": {
279256
"fieldType": "time"
280257
},
281258
"isRequired": true,
282-
"isArray": false,
283-
"isReadOnly": false
259+
"isArray": false
284260
},
285261
"timestampType": {
286262
"name": "timestampType",
287263
"type": {
288264
"fieldType": "timestamp"
289265
},
290266
"isRequired": true,
291-
"isArray": false,
292-
"isReadOnly": false
267+
"isArray": false
293268
},
294269
"enumType": {
295270
"name": "enumType",
296271
"type": {
297272
"fieldType": "string"
298273
},
299274
"isRequired": true,
300-
"isArray": false,
301-
"isReadOnly": false
275+
"isArray": false
302276
}
303277
}
304278
}

packages/amplify_datastore/example/lib/models/BelongsToModel.dart

Lines changed: 8 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,11 @@
1313
* permissions and limitations under the License.
1414
*/
1515

16-
import 'package:amplify_datastore_plugin_interface/amplify_datastore_plugin_interface.dart';
17-
import 'package:flutter/foundation.dart';
18-
1916
// ignore_for_file: public_member_api_docs
2017

2118
import 'ModelProvider.dart';
19+
import 'package:amplify_datastore_plugin_interface/amplify_datastore_plugin_interface.dart';
20+
import 'package:flutter/foundation.dart';
2221

2322
/** This is an auto generated class representing the BelongsToModel type in your schema. */
2423
@immutable
@@ -27,8 +26,6 @@ class BelongsToModel extends Model {
2726
final String id;
2827
final String? _name;
2928
final ChildModel? _child;
30-
final TemporalDateTime? _createdAt;
31-
final TemporalDateTime? _updatedAt;
3229

3330
@override
3431
getInstanceType() => classType;
@@ -64,20 +61,10 @@ class BelongsToModel extends Model {
6461
}
6562
}
6663

67-
TemporalDateTime? get createdAt {
68-
return _createdAt;
69-
}
70-
71-
TemporalDateTime? get updatedAt {
72-
return _updatedAt;
73-
}
74-
7564
const BelongsToModel._internal(
76-
{required this.id, required name, required child, createdAt, updatedAt})
65+
{required this.id, required name, required child})
7766
: _name = name,
78-
_child = child,
79-
_createdAt = createdAt,
80-
_updatedAt = updatedAt;
67+
_child = child;
8168

8269
factory BelongsToModel(
8370
{String? id, required String name, required ChildModel child}) {
@@ -108,20 +95,14 @@ class BelongsToModel extends Model {
10895
buffer.write("BelongsToModel {");
10996
buffer.write("id=" + "$id" + ", ");
11097
buffer.write("name=" + "$_name" + ", ");
111-
buffer.write(
112-
"child=" + (_child != null ? _child!.toString() : "null") + ", ");
113-
buffer.write("createdAt=" +
114-
(_createdAt != null ? _createdAt!.format() : "null") +
115-
", ");
116-
buffer.write(
117-
"updatedAt=" + (_updatedAt != null ? _updatedAt!.format() : "null"));
98+
buffer.write("child=" + (_child != null ? _child!.toString() : "null"));
11899
buffer.write("}");
119100

120101
return buffer.toString();
121102
}
122103

123104
BelongsToModel copyWith({String? id, String? name, ChildModel? child}) {
124-
return BelongsToModel._internal(
105+
return BelongsToModel(
125106
id: id ?? this.id, name: name ?? this.name, child: child ?? this.child);
126107
}
127108

@@ -131,21 +112,10 @@ class BelongsToModel extends Model {
131112
_child = json['child']?['serializedData'] != null
132113
? ChildModel.fromJson(
133114
new Map<String, dynamic>.from(json['child']['serializedData']))
134-
: null,
135-
_createdAt = json['createdAt'] != null
136-
? TemporalDateTime.fromString(json['createdAt'])
137-
: null,
138-
_updatedAt = json['updatedAt'] != null
139-
? TemporalDateTime.fromString(json['updatedAt'])
140115
: null;
141116

142-
Map<String, dynamic> toJson() => {
143-
'id': id,
144-
'name': _name,
145-
'child': _child?.toJson(),
146-
'createdAt': _createdAt?.format(),
147-
'updatedAt': _updatedAt?.format()
148-
};
117+
Map<String, dynamic> toJson() =>
118+
{'id': id, 'name': _name, 'child': _child?.toJson()};
149119

150120
static final QueryField ID = QueryField(fieldName: "belongsToModel.id");
151121
static final QueryField NAME = QueryField(fieldName: "name");
@@ -170,18 +140,6 @@ class BelongsToModel extends Model {
170140
isRequired: true,
171141
targetName: "belongsToModelChildId",
172142
ofModelName: (ChildModel).toString()));
173-
174-
modelSchemaDefinition.addField(ModelFieldDefinition.nonQueryField(
175-
fieldName: "createdAt",
176-
isRequired: false,
177-
isReadOnly: true,
178-
ofType: ModelFieldType(ModelFieldTypeEnum.dateTime)));
179-
180-
modelSchemaDefinition.addField(ModelFieldDefinition.nonQueryField(
181-
fieldName: "updatedAt",
182-
isRequired: false,
183-
isReadOnly: true,
184-
ofType: ModelFieldType(ModelFieldTypeEnum.dateTime)));
185143
});
186144
}
187145

0 commit comments

Comments
 (0)