@aws-amplify/graphql-model-transformer 1.3.6 → 1.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/lib/definitions.d.ts.map +1 -1
- package/lib/definitions.js +28 -2
- package/lib/definitions.js.map +1 -1
- package/lib/graphql-model-transformer.d.ts.map +1 -1
- package/lib/graphql-model-transformer.js +37 -35
- package/lib/graphql-model-transformer.js.map +1 -1
- package/lib/graphql-types/common.d.ts.map +1 -1
- package/lib/graphql-types/common.js +16 -18
- package/lib/graphql-types/common.js.map +1 -1
- package/lib/graphql-types/mutation.js +12 -12
- package/lib/graphql-types/mutation.js.map +1 -1
- package/lib/rds-lambda.zip +0 -0
- package/lib/resolvers/common.d.ts.map +1 -1
- package/lib/resolvers/common.js.map +1 -1
- package/lib/resolvers/dynamodb/mutation.d.ts.map +1 -1
- package/lib/resolvers/dynamodb/mutation.js +10 -8
- package/lib/resolvers/dynamodb/mutation.js.map +1 -1
- package/lib/resolvers/dynamodb/query.d.ts.map +1 -1
- package/lib/resolvers/dynamodb/query.js +1 -4
- package/lib/resolvers/dynamodb/query.js.map +1 -1
- package/lib/resolvers/dynamodb/subscriptions.d.ts.map +1 -1
- package/lib/resolvers/dynamodb/subscriptions.js.map +1 -1
- package/lib/resolvers/generators/rds-vtl-generator.d.ts.map +1 -1
- package/lib/resolvers/generators/rds-vtl-generator.js.map +1 -1
- package/lib/resolvers/generators/vtl-generator.d.ts.map +1 -1
- package/lib/resolvers/index.d.ts.map +1 -1
- package/lib/resolvers/index.js.map +1 -1
- package/lib/resolvers/rds/mutation.d.ts.map +1 -1
- package/lib/resolvers/rds/mutation.js.map +1 -1
- package/lib/resolvers/rds/query.d.ts.map +1 -1
- package/lib/resolvers/rds/query.js.map +1 -1
- package/lib/resolvers/rds/resolver.d.ts.map +1 -1
- package/lib/resolvers/rds/resolver.js +1 -1
- package/lib/resolvers/rds/resolver.js.map +1 -1
- package/lib/resources/dynamo-model-resource-generator.d.ts.map +1 -1
- package/lib/resources/dynamo-model-resource-generator.js.map +1 -1
- package/lib/resources/model-resource-generator.d.ts.map +1 -1
- package/lib/resources/model-resource-generator.js +12 -4
- package/lib/resources/model-resource-generator.js.map +1 -1
- package/lib/resources/rds-model-resource-generator.d.ts.map +1 -1
- package/lib/resources/rds-model-resource-generator.js +1 -1
- package/lib/resources/rds-model-resource-generator.js.map +1 -1
- package/package.json +7 -7
- package/rds-lambda/node_modules/.package-lock.json +215 -227
- package/rds-lambda/node_modules/@aws-sdk/client-ssm/package.json +17 -18
- package/rds-lambda/node_modules/@aws-sdk/client-sso/package.json +14 -15
- package/rds-lambda/node_modules/@aws-sdk/client-sso-oidc/package.json +14 -15
- package/rds-lambda/node_modules/@aws-sdk/client-sts/package.json +17 -18
- package/rds-lambda/node_modules/@aws-sdk/credential-provider-env/package.json +2 -2
- package/rds-lambda/node_modules/@aws-sdk/credential-provider-ini/package.json +6 -6
- package/rds-lambda/node_modules/@aws-sdk/credential-provider-node/package.json +7 -7
- package/rds-lambda/node_modules/@aws-sdk/credential-provider-process/package.json +2 -2
- package/rds-lambda/node_modules/@aws-sdk/credential-provider-sso/package.json +4 -4
- package/rds-lambda/node_modules/@aws-sdk/credential-provider-web-identity/package.json +2 -2
- package/rds-lambda/node_modules/@aws-sdk/middleware-host-header/package.json +2 -2
- package/rds-lambda/node_modules/@aws-sdk/middleware-logger/package.json +2 -2
- package/rds-lambda/node_modules/@aws-sdk/middleware-recursion-detection/package.json +2 -2
- package/rds-lambda/node_modules/@aws-sdk/middleware-sdk-sts/package.json +3 -3
- package/rds-lambda/node_modules/@aws-sdk/middleware-signing/package.json +2 -2
- package/rds-lambda/node_modules/@aws-sdk/middleware-user-agent/package.json +3 -3
- package/rds-lambda/node_modules/@aws-sdk/token-providers/package.json +3 -3
- package/rds-lambda/node_modules/@aws-sdk/types/package.json +2 -1
- package/rds-lambda/node_modules/@aws-sdk/util-endpoints/package.json +2 -2
- package/rds-lambda/node_modules/@aws-sdk/util-user-agent-browser/package.json +2 -2
- package/rds-lambda/node_modules/@aws-sdk/util-user-agent-node/package.json +2 -2
- package/rds-lambda/node_modules/@babel/compat-data/data/plugin-bugfixes.json +2 -0
- package/rds-lambda/node_modules/@babel/compat-data/data/plugins.json +8 -0
- package/rds-lambda/node_modules/@babel/compat-data/package.json +1 -1
- package/rds-lambda/node_modules/@babel/core/package.json +7 -7
- package/rds-lambda/node_modules/@babel/generator/package.json +2 -2
- package/rds-lambda/node_modules/@babel/helper-compilation-targets/package.json +5 -5
- package/rds-lambda/node_modules/@babel/helper-module-transforms/README.md +1 -1
- package/rds-lambda/node_modules/@babel/helper-module-transforms/package.json +10 -6
- package/rds-lambda/node_modules/@types/jest/README.md +1 -1
- package/rds-lambda/node_modules/@types/jest/package.json +2 -2
- package/rds-lambda/node_modules/@types/node/README.md +1 -1
- package/rds-lambda/node_modules/@types/node/package.json +2 -2
- package/rds-lambda/node_modules/caniuse-lite/package.json +1 -1
- package/rds-lambda/node_modules/commander/Readme.md +7 -2
- package/rds-lambda/node_modules/commander/package.json +17 -17
- package/rds-lambda/node_modules/electron-to-chromium/full-chromium-versions.json +1 -1
- package/rds-lambda/node_modules/electron-to-chromium/full-versions.json +1 -1
- package/rds-lambda/node_modules/electron-to-chromium/package.json +1 -1
- package/rds-lambda/node_modules/electron-to-chromium/versions.json +1 -1
- package/rds-lambda/node_modules/jest-snapshot/node_modules/semver/package.json +3 -3
- package/rds-lambda/node_modules/knex/CHANGELOG.md +63 -21
- package/rds-lambda/node_modules/knex/CONTRIBUTING.md +1 -1
- package/rds-lambda/node_modules/knex/LICENSE +22 -22
- package/rds-lambda/node_modules/knex/README.md +32 -31
- package/rds-lambda/node_modules/knex/UPGRADING.md +94 -82
- package/rds-lambda/node_modules/knex/knex.mjs +11 -0
- package/rds-lambda/node_modules/knex/lib/dialects/oracle/DEAD_CODE.md +3 -3
- package/rds-lambda/node_modules/knex/lib/migrations/migrate/stub/cjs.stub +15 -15
- package/rds-lambda/node_modules/knex/lib/migrations/migrate/stub/coffee.stub +13 -13
- package/rds-lambda/node_modules/knex/lib/migrations/migrate/stub/eg.stub +14 -14
- package/rds-lambda/node_modules/knex/lib/migrations/migrate/stub/js-schema.stub +22 -22
- package/rds-lambda/node_modules/knex/lib/migrations/migrate/stub/js.stub +22 -22
- package/rds-lambda/node_modules/knex/lib/migrations/migrate/stub/knexfile-coffee.stub +34 -34
- package/rds-lambda/node_modules/knex/lib/migrations/migrate/stub/knexfile-eg.stub +43 -43
- package/rds-lambda/node_modules/knex/lib/migrations/migrate/stub/knexfile-js.stub +47 -47
- package/rds-lambda/node_modules/knex/lib/migrations/migrate/stub/knexfile-ls.stub +35 -35
- package/rds-lambda/node_modules/knex/lib/migrations/migrate/stub/knexfile-ts.stub +47 -47
- package/rds-lambda/node_modules/knex/lib/migrations/migrate/stub/ls.stub +14 -14
- package/rds-lambda/node_modules/knex/lib/migrations/migrate/stub/mjs.stub +23 -23
- package/rds-lambda/node_modules/knex/lib/migrations/migrate/stub/ts-schema.stub +21 -21
- package/rds-lambda/node_modules/knex/lib/migrations/migrate/stub/ts.stub +21 -21
- package/rds-lambda/node_modules/knex/lib/migrations/seed/stub/coffee.stub +9 -9
- package/rds-lambda/node_modules/knex/lib/migrations/seed/stub/eg.stub +11 -11
- package/rds-lambda/node_modules/knex/lib/migrations/seed/stub/js.stub +13 -13
- package/rds-lambda/node_modules/knex/lib/migrations/seed/stub/ls.stub +11 -11
- package/rds-lambda/node_modules/knex/lib/migrations/seed/stub/mjs.stub +12 -12
- package/rds-lambda/node_modules/knex/lib/migrations/seed/stub/ts.stub +13 -13
- package/rds-lambda/node_modules/knex/package.json +21 -18
- package/rds-lambda/node_modules/knex/scripts/docker-compose.yml +2 -2
- package/rds-lambda/node_modules/knex/scripts/next-release-howto.md +1 -1
- package/rds-lambda/node_modules/knex/scripts/oracledb-install-driver-libs.sh +82 -82
- package/rds-lambda/node_modules/knex/scripts/release.sh +36 -34
- package/rds-lambda/node_modules/knex/scripts/stress-test/README.txt +18 -18
- package/rds-lambda/node_modules/knex/scripts/stress-test/docker-compose.yml +16 -16
- package/rds-lambda/node_modules/pg-connection-string/package.json +2 -2
- package/rds-lambda/node_modules/semver/package.json +19 -9
- package/rds-lambda/node_modules/ts-jest/node_modules/semver/package.json +3 -3
- package/rds-lambda/package-lock.json +215 -227
- package/src/__tests__/model-transformer.test.ts +130 -139
- package/src/__tests__/test-utils/helpers.ts +1 -1
- package/src/__tests__/test-utils/rds_utils.test.ts +29 -68
- package/src/definitions.ts +28 -2
- package/src/graphql-model-transformer.ts +72 -74
- package/src/graphql-types/common.ts +41 -41
- package/src/graphql-types/mutation.ts +12 -12
- package/src/resolvers/common.ts +1 -12
- package/src/resolvers/dynamodb/mutation.ts +16 -13
- package/src/resolvers/dynamodb/query.ts +6 -12
- package/src/resolvers/dynamodb/subscriptions.ts +1 -3
- package/src/resolvers/generators/rds-vtl-generator.ts +1 -4
- package/src/resolvers/generators/vtl-generator.ts +5 -5
- package/src/resolvers/index.ts +1 -3
- package/src/resolvers/rds/mutation.ts +17 -6
- package/src/resolvers/rds/query.ts +4 -12
- package/src/resolvers/rds/resolver.ts +8 -13
- package/src/resources/dynamo-model-resource-generator.ts +12 -22
- package/src/resources/model-resource-generator.ts +54 -24
- package/src/resources/rds-model-resource-generator.ts +9 -23
- package/tsconfig.json +4 -4
- package/tsconfig.tsbuildinfo +1 -1
- package/rds-lambda/node_modules/@nicolo-ribaudo/semver-v6/CHANGELOG.md +0 -70
- package/rds-lambda/node_modules/@nicolo-ribaudo/semver-v6/LICENSE +0 -15
- package/rds-lambda/node_modules/@nicolo-ribaudo/semver-v6/README.md +0 -454
- package/rds-lambda/node_modules/@nicolo-ribaudo/semver-v6/package.json +0 -28
- package/rds-lambda/node_modules/@nicolo-ribaudo/semver-v6/range.bnf +0 -16
- package/rds-lambda/node_modules/pg/node_modules/pg-connection-string/LICENSE +0 -21
- package/rds-lambda/node_modules/pg/node_modules/pg-connection-string/README.md +0 -77
- package/rds-lambda/node_modules/pg/node_modules/pg-connection-string/package.json +0 -40
- package/rds-lambda/node_modules/semver/CHANGELOG.md +0 -70
|
@@ -70,17 +70,17 @@ describe('ModelTransformer: ', () => {
|
|
|
70
70
|
resolverConfig: {
|
|
71
71
|
project: {
|
|
72
72
|
ConflictDetection: 'VERSION',
|
|
73
|
-
ConflictHandler: ConflictHandlerType.AUTOMERGE
|
|
74
|
-
}
|
|
73
|
+
ConflictHandler: ConflictHandlerType.AUTOMERGE,
|
|
74
|
+
},
|
|
75
75
|
},
|
|
76
76
|
});
|
|
77
77
|
const out = transformer.transform(alsoValidSchema);
|
|
78
78
|
expect(out).toBeDefined();
|
|
79
|
-
|
|
79
|
+
|
|
80
80
|
validateModelSchema(parse(out.schema));
|
|
81
81
|
parse(out.schema);
|
|
82
82
|
expect(out.schema).toMatchSnapshot();
|
|
83
|
-
expect(out.schema).toContain(
|
|
83
|
+
expect(out.schema).toContain('input NonModelTypeInput');
|
|
84
84
|
});
|
|
85
85
|
|
|
86
86
|
it('should support custom query overrides', () => {
|
|
@@ -111,7 +111,7 @@ describe('ModelTransformer: ', () => {
|
|
|
111
111
|
|
|
112
112
|
// This id should always be optional.
|
|
113
113
|
// aka a named type node aka name.value would not be set if it were a non null node
|
|
114
|
-
const idField = createPostInput!.fields!.find(f => f.name.value === 'id');
|
|
114
|
+
const idField = createPostInput!.fields!.find((f) => f.name.value === 'id');
|
|
115
115
|
expect((idField!.type as NamedTypeNode).name!.value).toEqual('ID');
|
|
116
116
|
const queryType = getObjectType(parsed, 'Query');
|
|
117
117
|
expect(queryType).toBeDefined();
|
|
@@ -120,7 +120,7 @@ describe('ModelTransformer: ', () => {
|
|
|
120
120
|
const subscriptionType = getObjectType(parsed, 'Subscription');
|
|
121
121
|
expect(subscriptionType).toBeDefined();
|
|
122
122
|
expectFields(subscriptionType!, ['onCreatePost', 'onUpdatePost', 'onDeletePost']);
|
|
123
|
-
const subField = subscriptionType!.fields!.find(f => f.name.value === 'onCreatePost');
|
|
123
|
+
const subField = subscriptionType!.fields!.find((f) => f.name.value === 'onCreatePost');
|
|
124
124
|
expect(subField).toBeDefined();
|
|
125
125
|
expect(subField!.directives!.length).toEqual(1);
|
|
126
126
|
expect(subField!.directives![0].name!.value).toEqual('aws_subscribe');
|
|
@@ -331,10 +331,10 @@ describe('ModelTransformer: ', () => {
|
|
|
331
331
|
validateModelSchema(schema);
|
|
332
332
|
|
|
333
333
|
const createPostInput: InputObjectTypeDefinitionNode = schema.definitions.find(
|
|
334
|
-
d => d.kind === 'InputObjectTypeDefinition' && d.name.value === 'CreatePostInput',
|
|
334
|
+
(d) => d.kind === 'InputObjectTypeDefinition' && d.name.value === 'CreatePostInput',
|
|
335
335
|
)! as InputObjectTypeDefinitionNode;
|
|
336
336
|
expect(createPostInput).toBeDefined();
|
|
337
|
-
const defaultIdField: InputValueDefinitionNode = createPostInput.fields!.find(f => f.name.value === 'id')!;
|
|
337
|
+
const defaultIdField: InputValueDefinitionNode = createPostInput.fields!.find((f) => f.name.value === 'id')!;
|
|
338
338
|
expect(defaultIdField).toBeDefined();
|
|
339
339
|
expect(getBaseType(defaultIdField.type)).toEqual('ID');
|
|
340
340
|
});
|
|
@@ -433,10 +433,10 @@ describe('ModelTransformer: ', () => {
|
|
|
433
433
|
validateModelSchema(schema);
|
|
434
434
|
|
|
435
435
|
const createPostInput: InputObjectTypeDefinitionNode = schema.definitions.find(
|
|
436
|
-
d => d.kind === 'InputObjectTypeDefinition' && d.name.value === 'CreatePostInput',
|
|
436
|
+
(d) => d.kind === 'InputObjectTypeDefinition' && d.name.value === 'CreatePostInput',
|
|
437
437
|
)! as InputObjectTypeDefinitionNode;
|
|
438
438
|
expect(createPostInput).toBeDefined();
|
|
439
|
-
const defaultIdField: InputValueDefinitionNode = createPostInput.fields!.find(f => f.name.value === 'id')!;
|
|
439
|
+
const defaultIdField: InputValueDefinitionNode = createPostInput.fields!.find((f) => f.name.value === 'id')!;
|
|
440
440
|
expect(defaultIdField).toBeDefined();
|
|
441
441
|
expect(getBaseType(defaultIdField.type)).toEqual('Int');
|
|
442
442
|
// It should not add default value for ctx.arg.id as id is of type Int
|
|
@@ -723,8 +723,8 @@ describe('ModelTransformer: ', () => {
|
|
|
723
723
|
resolverConfig: {
|
|
724
724
|
project: {
|
|
725
725
|
ConflictDetection: 'VERSION',
|
|
726
|
-
ConflictHandler: ConflictHandlerType.AUTOMERGE
|
|
727
|
-
}
|
|
726
|
+
ConflictHandler: ConflictHandlerType.AUTOMERGE,
|
|
727
|
+
},
|
|
728
728
|
},
|
|
729
729
|
});
|
|
730
730
|
const result = transformer.transform(validSchema);
|
|
@@ -752,8 +752,8 @@ describe('ModelTransformer: ', () => {
|
|
|
752
752
|
resolverConfig: {
|
|
753
753
|
project: {
|
|
754
754
|
ConflictDetection: 'VERSION',
|
|
755
|
-
ConflictHandler: ConflictHandlerType.AUTOMERGE
|
|
756
|
-
}
|
|
755
|
+
ConflictHandler: ConflictHandlerType.AUTOMERGE,
|
|
756
|
+
},
|
|
757
757
|
},
|
|
758
758
|
});
|
|
759
759
|
const result = transformer.transform(validSchema);
|
|
@@ -781,8 +781,8 @@ describe('ModelTransformer: ', () => {
|
|
|
781
781
|
resolverConfig: {
|
|
782
782
|
project: {
|
|
783
783
|
ConflictDetection: 'VERSION',
|
|
784
|
-
ConflictHandler: ConflictHandlerType.AUTOMERGE
|
|
785
|
-
}
|
|
784
|
+
ConflictHandler: ConflictHandlerType.AUTOMERGE,
|
|
785
|
+
},
|
|
786
786
|
},
|
|
787
787
|
});
|
|
788
788
|
|
|
@@ -809,8 +809,8 @@ describe('ModelTransformer: ', () => {
|
|
|
809
809
|
resolverConfig: {
|
|
810
810
|
project: {
|
|
811
811
|
ConflictDetection: 'VERSION',
|
|
812
|
-
ConflictHandler: ConflictHandlerType.AUTOMERGE
|
|
813
|
-
}
|
|
812
|
+
ConflictHandler: ConflictHandlerType.AUTOMERGE,
|
|
813
|
+
},
|
|
814
814
|
},
|
|
815
815
|
});
|
|
816
816
|
const result = transformer.transform(validSchema);
|
|
@@ -840,8 +840,8 @@ describe('ModelTransformer: ', () => {
|
|
|
840
840
|
resolverConfig: {
|
|
841
841
|
project: {
|
|
842
842
|
ConflictDetection: 'VERSION',
|
|
843
|
-
ConflictHandler: ConflictHandlerType.AUTOMERGE
|
|
844
|
-
}
|
|
843
|
+
ConflictHandler: ConflictHandlerType.AUTOMERGE,
|
|
844
|
+
},
|
|
845
845
|
},
|
|
846
846
|
});
|
|
847
847
|
|
|
@@ -910,8 +910,8 @@ describe('ModelTransformer: ', () => {
|
|
|
910
910
|
resolverConfig: {
|
|
911
911
|
project: {
|
|
912
912
|
ConflictDetection: 'VERSION',
|
|
913
|
-
ConflictHandler: ConflictHandlerType.AUTOMERGE
|
|
914
|
-
}
|
|
913
|
+
ConflictHandler: ConflictHandlerType.AUTOMERGE,
|
|
914
|
+
},
|
|
915
915
|
},
|
|
916
916
|
});
|
|
917
917
|
const result = transformer.transform(validSchema);
|
|
@@ -1074,42 +1074,41 @@ describe('ModelTransformer: ', () => {
|
|
|
1074
1074
|
const subscriptionType = getObjectType(parsed, 'Subscription');
|
|
1075
1075
|
expect(subscriptionType).toBeDefined();
|
|
1076
1076
|
|
|
1077
|
-
subscriptionType!.fields!.forEach(it => {
|
|
1077
|
+
subscriptionType!.fields!.forEach((it) => {
|
|
1078
1078
|
expect(it.name.value.length <= 50).toBeTruthy();
|
|
1079
1079
|
});
|
|
1080
1080
|
|
|
1081
1081
|
const iamStackResource = out.stacks.ThisIsAVeryLongNameModelThatShouldNotGenerateIAMRoleNamesOver64Characters;
|
|
1082
1082
|
expect(iamStackResource).toBeDefined();
|
|
1083
|
-
Template.fromJSON(iamStackResource)
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1083
|
+
Template.fromJSON(iamStackResource).hasResourceProperties('AWS::IAM::Role', {
|
|
1084
|
+
AssumeRolePolicyDocument: {
|
|
1085
|
+
Statement: [
|
|
1086
|
+
{
|
|
1087
|
+
Action: 'sts:AssumeRole',
|
|
1088
|
+
Effect: 'Allow',
|
|
1089
|
+
Principal: {
|
|
1090
|
+
Service: 'appsync.amazonaws.com',
|
|
1091
|
+
},
|
|
1092
|
+
},
|
|
1093
|
+
],
|
|
1094
|
+
Version: '2012-10-17',
|
|
1095
|
+
},
|
|
1096
|
+
RoleName: {
|
|
1097
|
+
'Fn::Join': [
|
|
1098
|
+
'',
|
|
1099
|
+
[
|
|
1100
|
+
'ThisIsAVeryLongNameM2d9fca-',
|
|
1087
1101
|
{
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1102
|
+
Ref: 'referencetotransformerrootstackGraphQLAPI20497F53ApiId',
|
|
1103
|
+
},
|
|
1104
|
+
'-',
|
|
1105
|
+
{
|
|
1106
|
+
Ref: 'referencetotransformerrootstackenv10C5A902Ref',
|
|
1093
1107
|
},
|
|
1094
1108
|
],
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
'Fn::Join': [
|
|
1099
|
-
'',
|
|
1100
|
-
[
|
|
1101
|
-
'ThisIsAVeryLongNameM2d9fca-',
|
|
1102
|
-
{
|
|
1103
|
-
Ref: 'referencetotransformerrootstackGraphQLAPI20497F53ApiId',
|
|
1104
|
-
},
|
|
1105
|
-
'-',
|
|
1106
|
-
{
|
|
1107
|
-
Ref: 'referencetotransformerrootstackenv10C5A902Ref',
|
|
1108
|
-
},
|
|
1109
|
-
],
|
|
1110
|
-
],
|
|
1111
|
-
},
|
|
1112
|
-
});
|
|
1109
|
+
],
|
|
1110
|
+
},
|
|
1111
|
+
});
|
|
1113
1112
|
|
|
1114
1113
|
validateModelSchema(parsed);
|
|
1115
1114
|
});
|
|
@@ -1137,7 +1136,7 @@ describe('ModelTransformer: ', () => {
|
|
|
1137
1136
|
|
|
1138
1137
|
expectFieldsOnInputType(createTodoInput!, ['id', 'name']);
|
|
1139
1138
|
|
|
1140
|
-
const idField = createTodoInput!.fields!.find(f => f.name.value === 'id');
|
|
1139
|
+
const idField = createTodoInput!.fields!.find((f) => f.name.value === 'id');
|
|
1141
1140
|
expect((idField!.type as NamedTypeNode).name!.value).toEqual('ID');
|
|
1142
1141
|
expect((idField!.type as NamedTypeNode).kind).toEqual('NamedType');
|
|
1143
1142
|
|
|
@@ -1175,54 +1174,53 @@ describe('ModelTransformer: ', () => {
|
|
|
1175
1174
|
expect(out.resolvers['Query.syncTodos.req.vtl']).toMatchSnapshot();
|
|
1176
1175
|
expect(out.resolvers['Query.syncTodos.res.vtl']).toMatchSnapshot();
|
|
1177
1176
|
// ds table
|
|
1178
|
-
Template.fromJSON(out.rootStack)
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
KeyType: 'HASH',
|
|
1184
|
-
},
|
|
1185
|
-
{
|
|
1186
|
-
AttributeName: 'ds_sk',
|
|
1187
|
-
KeyType: 'RANGE',
|
|
1188
|
-
},
|
|
1189
|
-
],
|
|
1190
|
-
AttributeDefinitions: [
|
|
1191
|
-
{
|
|
1192
|
-
AttributeName: 'ds_pk',
|
|
1193
|
-
AttributeType: 'S',
|
|
1194
|
-
},
|
|
1195
|
-
{
|
|
1196
|
-
AttributeName: 'ds_sk',
|
|
1197
|
-
AttributeType: 'S',
|
|
1198
|
-
},
|
|
1199
|
-
],
|
|
1200
|
-
BillingMode: 'PAY_PER_REQUEST',
|
|
1201
|
-
StreamSpecification: {
|
|
1202
|
-
StreamViewType: 'NEW_AND_OLD_IMAGES',
|
|
1177
|
+
Template.fromJSON(out.rootStack).hasResourceProperties('AWS::DynamoDB::Table', {
|
|
1178
|
+
KeySchema: [
|
|
1179
|
+
{
|
|
1180
|
+
AttributeName: 'ds_pk',
|
|
1181
|
+
KeyType: 'HASH',
|
|
1203
1182
|
},
|
|
1204
|
-
|
|
1205
|
-
'
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
{
|
|
1214
|
-
Ref: 'env',
|
|
1215
|
-
},
|
|
1216
|
-
],
|
|
1217
|
-
],
|
|
1183
|
+
{
|
|
1184
|
+
AttributeName: 'ds_sk',
|
|
1185
|
+
KeyType: 'RANGE',
|
|
1186
|
+
},
|
|
1187
|
+
],
|
|
1188
|
+
AttributeDefinitions: [
|
|
1189
|
+
{
|
|
1190
|
+
AttributeName: 'ds_pk',
|
|
1191
|
+
AttributeType: 'S',
|
|
1218
1192
|
},
|
|
1219
|
-
|
|
1220
|
-
AttributeName: '
|
|
1221
|
-
|
|
1193
|
+
{
|
|
1194
|
+
AttributeName: 'ds_sk',
|
|
1195
|
+
AttributeType: 'S',
|
|
1222
1196
|
},
|
|
1223
|
-
|
|
1197
|
+
],
|
|
1198
|
+
BillingMode: 'PAY_PER_REQUEST',
|
|
1199
|
+
StreamSpecification: {
|
|
1200
|
+
StreamViewType: 'NEW_AND_OLD_IMAGES',
|
|
1201
|
+
},
|
|
1202
|
+
TableName: {
|
|
1203
|
+
'Fn::Join': [
|
|
1204
|
+
'',
|
|
1205
|
+
[
|
|
1206
|
+
'AmplifyDataStore-',
|
|
1207
|
+
{
|
|
1208
|
+
'Fn::GetAtt': ['GraphQLAPI', 'ApiId'],
|
|
1209
|
+
},
|
|
1210
|
+
'-',
|
|
1211
|
+
{
|
|
1212
|
+
Ref: 'env',
|
|
1213
|
+
},
|
|
1214
|
+
],
|
|
1215
|
+
],
|
|
1216
|
+
},
|
|
1217
|
+
TimeToLiveSpecification: {
|
|
1218
|
+
AttributeName: '_ttl',
|
|
1219
|
+
Enabled: true,
|
|
1220
|
+
},
|
|
1221
|
+
});
|
|
1224
1222
|
});
|
|
1225
|
-
it(
|
|
1223
|
+
it('the conflict detection of per model rule should be respected', () => {
|
|
1226
1224
|
const validSchema = `
|
|
1227
1225
|
type Todo @model {
|
|
1228
1226
|
name: String
|
|
@@ -1235,22 +1233,22 @@ describe('ModelTransformer: ', () => {
|
|
|
1235
1233
|
const transformer = new GraphQLTransform({
|
|
1236
1234
|
resolverConfig: {
|
|
1237
1235
|
project: {
|
|
1238
|
-
ConflictDetection:
|
|
1239
|
-
ConflictHandler: ConflictHandlerType.AUTOMERGE
|
|
1236
|
+
ConflictDetection: 'VERSION',
|
|
1237
|
+
ConflictHandler: ConflictHandlerType.AUTOMERGE,
|
|
1240
1238
|
},
|
|
1241
1239
|
models: {
|
|
1242
1240
|
Todo: {
|
|
1243
|
-
ConflictDetection:
|
|
1241
|
+
ConflictDetection: 'VERSION',
|
|
1244
1242
|
ConflictHandler: ConflictHandlerType.LAMBDA,
|
|
1245
1243
|
LambdaConflictHandler: {
|
|
1246
|
-
name:
|
|
1247
|
-
}
|
|
1244
|
+
name: 'myTodoConflictHandler',
|
|
1245
|
+
},
|
|
1248
1246
|
},
|
|
1249
1247
|
Author: {
|
|
1250
|
-
ConflictDetection:
|
|
1251
|
-
ConflictHandler: ConflictHandlerType.AUTOMERGE
|
|
1252
|
-
}
|
|
1253
|
-
}
|
|
1248
|
+
ConflictDetection: 'VERSION',
|
|
1249
|
+
ConflictHandler: ConflictHandlerType.AUTOMERGE,
|
|
1250
|
+
},
|
|
1251
|
+
},
|
|
1254
1252
|
},
|
|
1255
1253
|
transformers: [new ModelTransformer()],
|
|
1256
1254
|
transformParameters: {
|
|
@@ -1262,49 +1260,42 @@ describe('ModelTransformer: ', () => {
|
|
|
1262
1260
|
const schema = parse(out.schema);
|
|
1263
1261
|
validateModelSchema(schema);
|
|
1264
1262
|
// nested stacks for models
|
|
1265
|
-
const todoStack = out.stacks[
|
|
1266
|
-
const authorStack = out.stacks[
|
|
1263
|
+
const todoStack = out.stacks['Todo'];
|
|
1264
|
+
const authorStack = out.stacks['Author'];
|
|
1267
1265
|
// Todo stack should have lambda for conflict detect rather than auto merge
|
|
1268
|
-
Template.fromJSON(todoStack).hasResourceProperties(
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
}
|
|
1275
|
-
}
|
|
1276
|
-
);
|
|
1266
|
+
Template.fromJSON(todoStack).hasResourceProperties('AWS::AppSync::FunctionConfiguration', {
|
|
1267
|
+
SyncConfig: {
|
|
1268
|
+
ConflictDetection: 'VERSION',
|
|
1269
|
+
ConflictHandler: 'LAMBDA',
|
|
1270
|
+
},
|
|
1271
|
+
});
|
|
1277
1272
|
Template.fromJSON(todoStack).resourcePropertiesCountIs(
|
|
1278
|
-
|
|
1273
|
+
'AWS::AppSync::FunctionConfiguration',
|
|
1279
1274
|
{
|
|
1280
1275
|
SyncConfig: {
|
|
1281
|
-
ConflictDetection:
|
|
1282
|
-
ConflictHandler:
|
|
1283
|
-
}
|
|
1276
|
+
ConflictDetection: 'VERSION',
|
|
1277
|
+
ConflictHandler: 'AUTOMERGE',
|
|
1278
|
+
},
|
|
1284
1279
|
},
|
|
1285
|
-
0
|
|
1280
|
+
0,
|
|
1286
1281
|
);
|
|
1287
1282
|
// Author stack should have automerge for conflict detect rather than lambda
|
|
1288
1283
|
Template.fromJSON(authorStack).resourcePropertiesCountIs(
|
|
1289
|
-
|
|
1284
|
+
'AWS::AppSync::FunctionConfiguration',
|
|
1290
1285
|
{
|
|
1291
1286
|
SyncConfig: {
|
|
1292
|
-
ConflictDetection:
|
|
1293
|
-
ConflictHandler:
|
|
1294
|
-
}
|
|
1287
|
+
ConflictDetection: 'VERSION',
|
|
1288
|
+
ConflictHandler: 'LAMBDA',
|
|
1289
|
+
},
|
|
1295
1290
|
},
|
|
1296
|
-
0
|
|
1291
|
+
0,
|
|
1297
1292
|
);
|
|
1298
|
-
Template.fromJSON(authorStack).hasResourceProperties(
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
}
|
|
1305
|
-
}
|
|
1306
|
-
);
|
|
1307
|
-
|
|
1293
|
+
Template.fromJSON(authorStack).hasResourceProperties('AWS::AppSync::FunctionConfiguration', {
|
|
1294
|
+
SyncConfig: {
|
|
1295
|
+
ConflictDetection: 'VERSION',
|
|
1296
|
+
ConflictHandler: 'AUTOMERGE',
|
|
1297
|
+
},
|
|
1298
|
+
});
|
|
1308
1299
|
});
|
|
1309
1300
|
it('should add the model parameters at the root sack', () => {
|
|
1310
1301
|
const modelParams = {
|
|
@@ -1383,7 +1374,7 @@ describe('ModelTransformer: ', () => {
|
|
|
1383
1374
|
transformers: [new ModelTransformer()],
|
|
1384
1375
|
transformParameters: {
|
|
1385
1376
|
sandboxModeEnabled: true,
|
|
1386
|
-
}
|
|
1377
|
+
},
|
|
1387
1378
|
});
|
|
1388
1379
|
const out = transformer.transform(validSchema);
|
|
1389
1380
|
expect(out).toBeDefined();
|
|
@@ -1394,12 +1385,12 @@ describe('ModelTransformer: ', () => {
|
|
|
1394
1385
|
const postType = getObjectType(schema, 'Post')!;
|
|
1395
1386
|
expect(postType).toBeDefined();
|
|
1396
1387
|
expect(postType.directives).toBeDefined();
|
|
1397
|
-
expect(postType.directives!.some(dir => dir.name.value === 'aws_api_key')).toEqual(true);
|
|
1388
|
+
expect(postType.directives!.some((dir) => dir.name.value === 'aws_api_key')).toEqual(true);
|
|
1398
1389
|
|
|
1399
1390
|
const tagType = getObjectType(schema, 'Tag')!;
|
|
1400
1391
|
expect(tagType).toBeDefined();
|
|
1401
1392
|
expect(tagType.directives).toBeDefined();
|
|
1402
|
-
expect(tagType.directives!.some(dir => dir.name.value === 'aws_api_key')).toEqual(true);
|
|
1393
|
+
expect(tagType.directives!.some((dir) => dir.name.value === 'aws_api_key')).toEqual(true);
|
|
1403
1394
|
|
|
1404
1395
|
// check operations
|
|
1405
1396
|
const queryType = getObjectType(schema, 'Query')!;
|
|
@@ -1410,7 +1401,7 @@ describe('ModelTransformer: ', () => {
|
|
|
1410
1401
|
expect(subscriptionType).toBeDefined();
|
|
1411
1402
|
|
|
1412
1403
|
for (const field of [...queryType.fields!, ...mutationType.fields!, ...subscriptionType.fields!]) {
|
|
1413
|
-
expect(field.directives!.some(dir => dir.name.value === 'aws_api_key')).toEqual(true);
|
|
1404
|
+
expect(field.directives!.some((dir) => dir.name.value === 'aws_api_key')).toEqual(true);
|
|
1414
1405
|
}
|
|
1415
1406
|
});
|
|
1416
1407
|
|
|
@@ -43,7 +43,7 @@ export function doNotExpectFields(type: ObjectTypeDefinitionNode, fields: string
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
export function verifyInputCount(doc: DocumentNode, type: string, count: number): boolean {
|
|
46
|
-
return doc.definitions.filter(def => def.kind === Kind.INPUT_OBJECT_TYPE_DEFINITION && def.name.value === type).length == count;
|
|
46
|
+
return doc.definitions.filter((def) => def.kind === Kind.INPUT_OBJECT_TYPE_DEFINITION && def.name.value === type).length == count;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
export function getFieldOnInputType(type: InputObjectTypeDefinitionNode, field: string): InputValueDefinitionNode {
|
|
@@ -4,10 +4,7 @@ describe('filterToRdsExpression', () => {
|
|
|
4
4
|
// QueryGroup - and, or
|
|
5
5
|
it('should convert and: QueryGroup', () => {
|
|
6
6
|
const filter = {
|
|
7
|
-
and: [
|
|
8
|
-
{ id: { eq: '123' } },
|
|
9
|
-
{ name: { eq: 'Amplify' } },
|
|
10
|
-
],
|
|
7
|
+
and: [{ id: { eq: '123' } }, { name: { eq: 'Amplify' } }],
|
|
11
8
|
};
|
|
12
9
|
const queryExpression = toRDSQueryExpression(filter);
|
|
13
10
|
expect(queryExpression.rawSql).toEqual('((id = ?) AND (name = ?))');
|
|
@@ -15,10 +12,7 @@ describe('filterToRdsExpression', () => {
|
|
|
15
12
|
});
|
|
16
13
|
it('should convert or: QueryGroup', () => {
|
|
17
14
|
const filter = {
|
|
18
|
-
or: [
|
|
19
|
-
{ id: { eq: '123' } },
|
|
20
|
-
{ name: { eq: 'Amplify' } },
|
|
21
|
-
],
|
|
15
|
+
or: [{ id: { eq: '123' } }, { name: { eq: 'Amplify' } }],
|
|
22
16
|
};
|
|
23
17
|
const queryExpression = toRDSQueryExpression(filter);
|
|
24
18
|
expect(queryExpression.rawSql).toEqual('((id = ?) OR (name = ?))');
|
|
@@ -133,13 +127,15 @@ describe('filterToRdsExpression', () => {
|
|
|
133
127
|
expect(queryExpression.queryParams).toEqual(['123', '18', '60', 'AWS']);
|
|
134
128
|
});
|
|
135
129
|
|
|
136
|
-
test(
|
|
130
|
+
test("filterToRdsExpression > should throw error if between: doesn't have 2 values", () => {
|
|
137
131
|
const filter = {
|
|
138
132
|
id: { eq: '123' },
|
|
139
133
|
age: { between: ['18'] },
|
|
140
134
|
org: { ne: 'AWS' },
|
|
141
135
|
};
|
|
142
|
-
expect(() => {
|
|
136
|
+
expect(() => {
|
|
137
|
+
toRDSQueryExpression(filter);
|
|
138
|
+
}).toThrowError(/between condition must have two values/);
|
|
143
139
|
});
|
|
144
140
|
|
|
145
141
|
// nested QueryGroup & Operators
|
|
@@ -148,10 +144,7 @@ describe('filterToRdsExpression', () => {
|
|
|
148
144
|
and: [
|
|
149
145
|
{ id: { eq: '123' } },
|
|
150
146
|
{
|
|
151
|
-
or: [
|
|
152
|
-
{ name: { eq: 'Amplify' } },
|
|
153
|
-
{ org: { eq: 'AWS' } },
|
|
154
|
-
],
|
|
147
|
+
or: [{ name: { eq: 'Amplify' } }, { org: { eq: 'AWS' } }],
|
|
155
148
|
},
|
|
156
149
|
],
|
|
157
150
|
};
|
|
@@ -165,10 +158,7 @@ describe('filterToRdsExpression', () => {
|
|
|
165
158
|
or: [
|
|
166
159
|
{ id: { eq: '123' } },
|
|
167
160
|
{
|
|
168
|
-
and: [
|
|
169
|
-
{ name: { eq: 'Amplify' } },
|
|
170
|
-
{ org: { eq: 'AWS' } },
|
|
171
|
-
],
|
|
161
|
+
and: [{ name: { eq: 'Amplify' } }, { org: { eq: 'AWS' } }],
|
|
172
162
|
},
|
|
173
163
|
],
|
|
174
164
|
};
|
|
@@ -181,10 +171,7 @@ describe('filterToRdsExpression', () => {
|
|
|
181
171
|
and: [
|
|
182
172
|
{ id: { eq: '123' } },
|
|
183
173
|
{
|
|
184
|
-
and: [
|
|
185
|
-
{ name: { eq: 'Amplify' } },
|
|
186
|
-
{ org: { eq: 'AWS' } },
|
|
187
|
-
],
|
|
174
|
+
and: [{ name: { eq: 'Amplify' } }, { org: { eq: 'AWS' } }],
|
|
188
175
|
},
|
|
189
176
|
],
|
|
190
177
|
};
|
|
@@ -201,10 +188,7 @@ describe('filterToRdsExpression', () => {
|
|
|
201
188
|
or: [
|
|
202
189
|
{ name: { eq: 'Amplify' } },
|
|
203
190
|
{
|
|
204
|
-
and: [
|
|
205
|
-
{ org: { eq: 'AWS' } },
|
|
206
|
-
{ age: { between: ['18', '60'] } },
|
|
207
|
-
],
|
|
191
|
+
and: [{ org: { eq: 'AWS' } }, { age: { between: ['18', '60'] } }],
|
|
208
192
|
},
|
|
209
193
|
],
|
|
210
194
|
},
|
|
@@ -223,11 +207,7 @@ describe('filterToRdsExpression', () => {
|
|
|
223
207
|
or: [
|
|
224
208
|
{ name: { eq: 'Amplify' } },
|
|
225
209
|
{
|
|
226
|
-
and: [
|
|
227
|
-
{ org: { eq: 'AWS' } },
|
|
228
|
-
{ age: { between: ['18', '60'] } },
|
|
229
|
-
{ name: { beginsWith: 'Amplify' } },
|
|
230
|
-
],
|
|
210
|
+
and: [{ org: { eq: 'AWS' } }, { age: { between: ['18', '60'] } }, { name: { beginsWith: 'Amplify' } }],
|
|
231
211
|
},
|
|
232
212
|
],
|
|
233
213
|
},
|
|
@@ -246,22 +226,17 @@ describe('filterToRdsExpression', () => {
|
|
|
246
226
|
or: [
|
|
247
227
|
{ name: { eq: 'Amplify' } },
|
|
248
228
|
{
|
|
249
|
-
and: [
|
|
250
|
-
{ org: { ne: 'AWS' } },
|
|
251
|
-
{ age: { between: ['18', '60'] } },
|
|
252
|
-
{ name: { beginsWith: 'Amplify' } },
|
|
253
|
-
],
|
|
229
|
+
and: [{ org: { ne: 'AWS' } }, { age: { between: ['18', '60'] } }, { name: { beginsWith: 'Amplify' } }],
|
|
254
230
|
},
|
|
255
231
|
],
|
|
256
232
|
},
|
|
257
233
|
],
|
|
258
|
-
or: [
|
|
259
|
-
{ name: { eq: 'Amplify' } },
|
|
260
|
-
{ org: { eq: 'AWS' } },
|
|
261
|
-
],
|
|
234
|
+
or: [{ name: { eq: 'Amplify' } }, { org: { eq: 'AWS' } }],
|
|
262
235
|
};
|
|
263
236
|
const queryExpression = toRDSQueryExpression(filter);
|
|
264
|
-
expect(queryExpression.rawSql).toEqual(
|
|
237
|
+
expect(queryExpression.rawSql).toEqual(
|
|
238
|
+
"(id != ? AND ((name = ?) OR ((org != ?) AND (age BETWEEN ? AND ?) AND (name LIKE '?%'))) AND (name = ?) OR (org = ?))",
|
|
239
|
+
);
|
|
265
240
|
expect(queryExpression.queryParams).toEqual(['123', 'Amplify', 'AWS', '18', '60', 'Amplify', 'Amplify', 'AWS']);
|
|
266
241
|
});
|
|
267
242
|
|
|
@@ -271,20 +246,15 @@ describe('filterToRdsExpression', () => {
|
|
|
271
246
|
or: [
|
|
272
247
|
{ name: { eq: 'Amplify' } },
|
|
273
248
|
{
|
|
274
|
-
and: [
|
|
275
|
-
{ org: { eq: 'AWS' } },
|
|
276
|
-
{ age: { between: ['18', '60'] } },
|
|
277
|
-
{ name: { eq: 'Amplify' } },
|
|
278
|
-
],
|
|
249
|
+
and: [{ org: { eq: 'AWS' } }, { age: { between: ['18', '60'] } }, { name: { eq: 'Amplify' } }],
|
|
279
250
|
},
|
|
280
251
|
],
|
|
281
|
-
and: [
|
|
282
|
-
{ name: { eq: 'Amplify' } },
|
|
283
|
-
{ org: { eq: 'AWS' } },
|
|
284
|
-
],
|
|
252
|
+
and: [{ name: { eq: 'Amplify' } }, { org: { eq: 'AWS' } }],
|
|
285
253
|
};
|
|
286
254
|
const queryExpression = toRDSQueryExpression(filter);
|
|
287
|
-
expect(queryExpression.rawSql).toEqual(
|
|
255
|
+
expect(queryExpression.rawSql).toEqual(
|
|
256
|
+
"(name LIKE '?%' AND (name = ?) OR ((org = ?) AND (age BETWEEN ? AND ?) AND (name = ?)) AND (name = ?) AND (org = ?))",
|
|
257
|
+
);
|
|
288
258
|
expect(queryExpression.queryParams).toEqual(['A', 'Amplify', 'AWS', '18', '60', 'Amplify', 'Amplify', 'AWS']);
|
|
289
259
|
});
|
|
290
260
|
|
|
@@ -327,9 +297,7 @@ describe('filterToRdsExpression', () => {
|
|
|
327
297
|
|
|
328
298
|
it('should work on size: eq: operator along with and: QueryGroup', () => {
|
|
329
299
|
const filter = {
|
|
330
|
-
and: [
|
|
331
|
-
{ id: { eq: '123', size: { eq: 1 } } },
|
|
332
|
-
],
|
|
300
|
+
and: [{ id: { eq: '123', size: { eq: 1 } } }],
|
|
333
301
|
};
|
|
334
302
|
const queryExpression = toRDSQueryExpression(filter);
|
|
335
303
|
expect(queryExpression.rawSql).toEqual('((id = ? AND LENGTH (id) = ?))');
|
|
@@ -338,12 +306,8 @@ describe('filterToRdsExpression', () => {
|
|
|
338
306
|
|
|
339
307
|
it('should work on size: eq: operator along with or: QueryGroup', () => {
|
|
340
308
|
const filter = {
|
|
341
|
-
or: [
|
|
342
|
-
|
|
343
|
-
],
|
|
344
|
-
and: [
|
|
345
|
-
{ age: { eq: '30', size: { eq: 3 } } },
|
|
346
|
-
],
|
|
309
|
+
or: [{ id: { eq: '123', size: { eq: 2 } } }],
|
|
310
|
+
and: [{ age: { eq: '30', size: { eq: 3 } } }],
|
|
347
311
|
};
|
|
348
312
|
const queryExpression = toRDSQueryExpression(filter);
|
|
349
313
|
expect(queryExpression.rawSql).toEqual('((id = ? AND LENGTH (id) = ?) AND (age = ? AND LENGTH (age) = ?))');
|
|
@@ -355,18 +319,15 @@ describe('filterToRdsExpression', () => {
|
|
|
355
319
|
or: [
|
|
356
320
|
{ id: { eq: '123', size: { eq: 2 } } },
|
|
357
321
|
{
|
|
358
|
-
and: [
|
|
359
|
-
{ age: { eq: '30', size: { eq: 3 } } },
|
|
360
|
-
],
|
|
322
|
+
and: [{ age: { eq: '30', size: { eq: 3 } } }],
|
|
361
323
|
},
|
|
362
324
|
],
|
|
363
|
-
and: [
|
|
364
|
-
{ age: { eq: '20', size: { eq: 3 } } },
|
|
365
|
-
{ org: { eq: 'AWS', size: { eq: 3 } } },
|
|
366
|
-
],
|
|
325
|
+
and: [{ age: { eq: '20', size: { eq: 3 } } }, { org: { eq: 'AWS', size: { eq: 3 } } }],
|
|
367
326
|
};
|
|
368
327
|
const queryExpression = toRDSQueryExpression(filter);
|
|
369
|
-
expect(queryExpression.rawSql).toEqual(
|
|
328
|
+
expect(queryExpression.rawSql).toEqual(
|
|
329
|
+
'((id = ? AND LENGTH (id) = ?) OR ((age = ? AND LENGTH (age) = ?)) AND (age = ? AND LENGTH (age) = ?) AND (org = ? AND LENGTH (org) = ?))',
|
|
330
|
+
);
|
|
370
331
|
expect(queryExpression.queryParams).toEqual(['123', 2, '30', 3, '20', 3, 'AWS', 3]);
|
|
371
332
|
});
|
|
372
333
|
});
|