Skip to content

Commit

Permalink
Merge branch 'main' into merge-rc-to-main-0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Travis Sheppard committed Feb 11, 2022
2 parents 824d9a6 + b5a1c3a commit af07793
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class TemporalDateTime implements Comparable<TemporalDateTime> {
dateTime.microsecond);

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

_offset = offset;
Expand All @@ -75,7 +75,7 @@ class TemporalDateTime implements Comparable<TemporalDateTime> {
/// +hh:mm
/// +hh:mm:ss
TemporalDateTime.fromString(String iso8601String) {
RegExp regExp = new RegExp(
RegExp regExp = RegExp(
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])?))',
caseSensitive: false,
multiLine: false);
Expand All @@ -90,7 +90,7 @@ class TemporalDateTime implements Comparable<TemporalDateTime> {
}

if (regexString != iso8601String) {
throw new Exception("invalid string input");
throw Exception("invalid string input");
}

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

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

if (_offset != null) {
if (_offset!.inSeconds == 0) {
Expand Down
12 changes: 6 additions & 6 deletions packages/amplify_core/test/amplify_temporal_datetime_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ void main() {

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

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

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

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

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

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

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

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

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

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

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

test('AWSDateTime from string YYYY-MM-DDThh:mm:ss.sss+hh:mm:ss success',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import 'boolean_query_predicate_test.dart' as boolean_query_predicate_tests;
import 'enum_query_predicate_test.dart' as enum_query_predicate_tests;
import 'compound_query_predicate_test.dart' as compound_query_predicate_tests;
import 'aws_date_query_predicate_test.dart' as aws_date_query_predicate_test;
import 'aws_date_time_query_predicate_test.dart'
as aws_date_time_query_predicate_test;
import 'aws_time_query_predicate_test.dart' as aws_time_query_predicate_test;
import 'aws_timestamp_query_predicate_test.dart'
as aws_timestamp_query_predicate_tests;
Expand All @@ -38,9 +40,7 @@ void main() async {
enum_query_predicate_tests.main();
compound_query_predicate_tests.main();
aws_date_query_predicate_test.main();
// TODO: enable AWSDateTime test suite when this issue gets resolved:
// https://github.com/aws-amplify/amplify-flutter/issues/1245
// aws_date_time_query_predicate_test.main();
aws_date_time_query_predicate_test.main();
aws_time_query_predicate_test.main();
aws_timestamp_query_predicate_tests.main();
});
Expand Down
11 changes: 1 addition & 10 deletions packages/amplify_datastore/example/tool/schema.graphql
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# This "input" configures a global authorization rule to enable public access to
# all models in this schema. Learn more about authorization rules here: https://docs.amplify.aws/cli/graphql/authorization-rules
input AMPLIFY {
globalAuthRule: AuthRule = { allow: public }
} # FOR TESTING ONLY!
}
type Blog @model {
id: ID!
name: String!
Expand Down Expand Up @@ -33,7 +31,6 @@ type Tag @model {
posts: [Post] @manyToMany(relationName: "PostTags")
}

# scalar types, enum and CustomType
type ModelWithAppsyncScalarTypes @model {
id: ID!
stringValue: String
Expand Down Expand Up @@ -112,9 +109,6 @@ type SimpleCustomType {
foo: String!
}

# Model relationships

# models with has one relationship
type HasOneParent @model {
id: ID!
name: String
Expand All @@ -128,7 +122,6 @@ type HasOneChild @model {
name: String
}

# models with has many relationship
type HasManyParent @model {
id: ID!
name: String
Expand Down Expand Up @@ -175,7 +168,6 @@ type HasManyChildBiDirectionalExplicit @model {
@belongsTo(fields: ["hasManyParentId"])
}

# models with belongs to relationship
type BelongsToParent @model {
id: ID!
name: String
Expand All @@ -196,7 +188,6 @@ type BelongsToChildExplicit @model {
belongsToParent: BelongsToParent @belongsTo(fields: ["belongsToParentID"])
}

# models with multiple relationships
type MultiRelatedMeeting @model {
id: ID! @primaryKey
title: String!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"field": "created",
"fieldOperator": {
"operatorName": "equal",
"value": "2020-01-01T00:00:00Z"
"value": "2020-01-01T00:00:00.000000000Z"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"id": "9fc5fab4-37ff-4566-97e5-19c5d58a4c22",
"title": "New Post being saved",
"rating": 10,
"created": "2020-11-12T03:15:48+03:18",
"created": "2020-11-12T03:15:48.000000000+03:18",
"likeCount": null,
"blog": null,
"comments": null,
Expand Down

0 comments on commit af07793

Please sign in to comment.