Skip to content

Commit af07793

Browse files
author
Travis Sheppard
committed
Merge branch 'main' into merge-rc-to-main-0.4.0
2 parents 824d9a6 + b5a1c3a commit af07793

File tree

6 files changed

+18
-27
lines changed

6 files changed

+18
-27
lines changed

packages/amplify_core/lib/src/types/temporal/temporal_datetime.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class TemporalDateTime implements Comparable<TemporalDateTime> {
6060
dateTime.microsecond);
6161

6262
if (offset.inDays > 0) {
63-
throw new Exception("Cannot have an offset in days (hh:mm:ss)");
63+
throw Exception("Cannot have an offset in days (hh:mm:ss)");
6464
}
6565

6666
_offset = offset;
@@ -75,7 +75,7 @@ class TemporalDateTime implements Comparable<TemporalDateTime> {
7575
/// +hh:mm
7676
/// +hh:mm:ss
7777
TemporalDateTime.fromString(String iso8601String) {
78-
RegExp regExp = new RegExp(
78+
RegExp regExp = RegExp(
7979
r'^([0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9]:[0-5][0-9](:[0-5][0-9](\.([0-9]{1,9}))?)?)((z|Z)|((\+|-)[0-2][0-9]:[0-5][0-9](:[0-5][0-9])?))',
8080
caseSensitive: false,
8181
multiLine: false);
@@ -90,7 +90,7 @@ class TemporalDateTime implements Comparable<TemporalDateTime> {
9090
}
9191

9292
if (regexString != iso8601String) {
93-
throw new Exception("invalid string input");
93+
throw Exception("invalid string input");
9494
}
9595

9696
// Extract Time
@@ -141,9 +141,9 @@ class TemporalDateTime implements Comparable<TemporalDateTime> {
141141
buffer.write(isoString.substring(0, isoString.length - 4));
142142

143143
int totalMicroseconds = _nanoseconds + Temporal.getNanoseconds(_dateTime);
144-
if (totalMicroseconds > 0) {
145-
buffer.write("." + totalMicroseconds.toString().padLeft(9, "0"));
146-
}
144+
// ensure DateTime strings stored in SQLite to be in the same format
145+
// and string based DataTime comparison to be accurate
146+
buffer.write("." + totalMicroseconds.toString().padLeft(9, "0"));
147147

148148
if (_offset != null) {
149149
if (_offset!.inSeconds == 0) {

packages/amplify_core/test/amplify_temporal_datetime_test.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@ void main() {
4646

4747
expect(time.getOffset(), Duration());
4848
expect(time.getDateTimeInUtc(), DateTime.utc(1995, 05, 03, 03, 30));
49-
expect(time.format(), "1995-05-03T03:30:00Z");
49+
expect(time.format(), "1995-05-03T03:30:00.000000000Z");
5050
});
5151

5252
test('AWSDateTime from string YYYY-MM-DDThh:mm:ssZ success', () async {
5353
TemporalDateTime time = TemporalDateTime.fromString("1995-05-03T03:30:25Z");
5454

5555
expect(time.getOffset(), Duration());
5656
expect(time.getDateTimeInUtc(), DateTime.utc(1995, 05, 03, 03, 30, 25));
57-
expect(time.format(), "1995-05-03T03:30:25Z");
57+
expect(time.format(), "1995-05-03T03:30:25.000000000Z");
5858
});
5959

6060
test('AWSDateTime from string YYYY-MM-DDThh:mm:ss.sssZ success', () async {
@@ -74,7 +74,7 @@ void main() {
7474

7575
expect(time.getOffset(), duration);
7676
expect(time.getDateTimeInUtc(), DateTime.utc(1995, 05, 03, 03, 30));
77-
expect(time.format(), "1995-05-03T03:30:00+03:25");
77+
expect(time.format(), "1995-05-03T03:30:00.000000000+03:25");
7878
});
7979

8080
test('AWSDateTime from string YYYY-MM-DDThh:mm-hh:mm success', () async {
@@ -84,7 +84,7 @@ void main() {
8484

8585
expect(time.getOffset(), duration);
8686
expect(time.getDateTimeInUtc(), DateTime.utc(1995, 05, 03, 03, 30));
87-
expect(time.format(), "1995-05-03T03:30:00-03:25");
87+
expect(time.format(), "1995-05-03T03:30:00.000000000-03:25");
8888
});
8989

9090
test('AWSDateTime from string YYYY-MM-DDThh:mm+hh:mm:ss success', () async {
@@ -94,7 +94,7 @@ void main() {
9494

9595
expect(time.getOffset(), duration);
9696
expect(time.getDateTimeInUtc(), DateTime.utc(1995, 05, 03, 03, 30));
97-
expect(time.format(), "1995-05-03T03:30:00+03:25:55");
97+
expect(time.format(), "1995-05-03T03:30:00.000000000+03:25:55");
9898
});
9999

100100
test('AWSDateTime from string YYYY-MM-DDThh:mm:ss+hh:mm:ss success',
@@ -105,7 +105,7 @@ void main() {
105105

106106
expect(time.getOffset(), duration);
107107
expect(time.getDateTimeInUtc(), DateTime.utc(1995, 05, 03, 03, 30, 25));
108-
expect(time.format(), "1995-05-03T03:30:25+03:25:55");
108+
expect(time.format(), "1995-05-03T03:30:25.000000000+03:25:55");
109109
});
110110

111111
test('AWSDateTime from string YYYY-MM-DDThh:mm:ss.sss+hh:mm:ss success',

packages/amplify_datastore/example/integration_test/query_test/query_predicate_test/query_predicate_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ import 'boolean_query_predicate_test.dart' as boolean_query_predicate_tests;
2323
import 'enum_query_predicate_test.dart' as enum_query_predicate_tests;
2424
import 'compound_query_predicate_test.dart' as compound_query_predicate_tests;
2525
import 'aws_date_query_predicate_test.dart' as aws_date_query_predicate_test;
26+
import 'aws_date_time_query_predicate_test.dart'
27+
as aws_date_time_query_predicate_test;
2628
import 'aws_time_query_predicate_test.dart' as aws_time_query_predicate_test;
2729
import 'aws_timestamp_query_predicate_test.dart'
2830
as aws_timestamp_query_predicate_tests;
@@ -38,9 +40,7 @@ void main() async {
3840
enum_query_predicate_tests.main();
3941
compound_query_predicate_tests.main();
4042
aws_date_query_predicate_test.main();
41-
// TODO: enable AWSDateTime test suite when this issue gets resolved:
42-
// https://github.com/aws-amplify/amplify-flutter/issues/1245
43-
// aws_date_time_query_predicate_test.main();
43+
aws_date_time_query_predicate_test.main();
4444
aws_time_query_predicate_test.main();
4545
aws_timestamp_query_predicate_tests.main();
4646
});

packages/amplify_datastore/example/tool/schema.graphql

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
# This "input" configures a global authorization rule to enable public access to
2-
# all models in this schema. Learn more about authorization rules here: https://docs.amplify.aws/cli/graphql/authorization-rules
31
input AMPLIFY {
42
globalAuthRule: AuthRule = { allow: public }
5-
} # FOR TESTING ONLY!
3+
}
64
type Blog @model {
75
id: ID!
86
name: String!
@@ -33,7 +31,6 @@ type Tag @model {
3331
posts: [Post] @manyToMany(relationName: "PostTags")
3432
}
3533

36-
# scalar types, enum and CustomType
3734
type ModelWithAppsyncScalarTypes @model {
3835
id: ID!
3936
stringValue: String
@@ -112,9 +109,6 @@ type SimpleCustomType {
112109
foo: String!
113110
}
114111

115-
# Model relationships
116-
117-
# models with has one relationship
118112
type HasOneParent @model {
119113
id: ID!
120114
name: String
@@ -128,7 +122,6 @@ type HasOneChild @model {
128122
name: String
129123
}
130124

131-
# models with has many relationship
132125
type HasManyParent @model {
133126
id: ID!
134127
name: String
@@ -175,7 +168,6 @@ type HasManyChildBiDirectionalExplicit @model {
175168
@belongsTo(fields: ["hasManyParentId"])
176169
}
177170

178-
# models with belongs to relationship
179171
type BelongsToParent @model {
180172
id: ID!
181173
name: String
@@ -196,7 +188,6 @@ type BelongsToChildExplicit @model {
196188
belongsToParent: BelongsToParent @belongsTo(fields: ["belongsToParentID"])
197189
}
198190

199-
# models with multiple relationships
200191
type MultiRelatedMeeting @model {
201192
id: ID! @primaryKey
202193
title: String!

packages/amplify_datastore/test/resources/query_predicate/temporal_predicate.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"field": "created",
44
"fieldOperator": {
55
"operatorName": "equal",
6-
"value": "2020-01-01T00:00:00Z"
6+
"value": "2020-01-01T00:00:00.000000000Z"
77
}
88
}
99
}

packages/amplify_datastore/test/resources/save_api/request/instance_without_predicate.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"id": "9fc5fab4-37ff-4566-97e5-19c5d58a4c22",
55
"title": "New Post being saved",
66
"rating": 10,
7-
"created": "2020-11-12T03:15:48+03:18",
7+
"created": "2020-11-12T03:15:48.000000000+03:18",
88
"likeCount": null,
99
"blog": null,
1010
"comments": null,

0 commit comments

Comments
 (0)