-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/custom pk flutter impl #394
Feat/custom pk flutter impl #394
Conversation
This pull request introduces 1 alert when merging 2ce373d into 84831b5 - view on LGTM.com new alerts:
|
This pull request introduces 1 alert when merging 69c7f70 into 84831b5 - view on LGTM.com new alerts:
|
This pull request introduces 1 alert when merging 9c17617 into 84831b5 - view on LGTM.com new alerts:
|
This pull request introduces 1 alert when merging fee40d3 into 84831b5 - view on LGTM.com new alerts:
|
Codecov Report
@@ Coverage Diff @@
## custom-pk-flutter #394 +/- ##
====================================================
Coverage ? 85.49%
====================================================
Files ? 145
Lines ? 6866
Branches ? 1781
====================================================
Hits ? 5870
Misses ? 905
Partials ? 91 Continue to review full report at Codecov.
|
This pull request introduces 1 alert when merging 38927cb into 84831b5 - view on LGTM.com new alerts:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The custom PK change LGTM. I have some questions as follows:
- I notice some general changes such as changing the comment format to
///
, removing thenew
keyword and addingconst
keyword. It is better to include the description for these if they are intended. - For scenario where
id
is PK and sort key fields are defined, I can also see the sort keys are defined in the new model identifier class. However, they are not actually treated as a composite key type. I wonder what is the use case of it comparing to custom PK with SK. - For the getting primary key info, see the comments below.
@@ -999,6 +1146,18 @@ export class AppSyncModelDartVisitor< | |||
}); | |||
} | |||
|
|||
protected getModelIdentifierFields(model: CodeGenModel): CodeGenField[] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: This method can work until the v1 transformer is deprecated(as @key
is v1). In long term, this method can take advantage of the change in base visitor, where the model fields can be traversed to find pk field and corresponding pk type info (including pk type and sort key fields). The pk name can also be found as well.
const primaryKeyField = model.fields.find(field => field.primaryKeyInfo)!;
const { sortKeyFields } = primaryKeyField.primaryKeyInfo!
Thanks @AaronZyLee for reviewing -
Yes is to conform Dart conventions. I will separate the change out as a separate PR.
I wasn't aware of this scenario "where
Will update the impl. |
This pull request introduces 1 alert when merging b255a18 into 84831b5 - view on LGTM.com new alerts:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you fix the bot alert? Otherwise LGTM
* fix(appsync-dart-visitor): update broken test snapshot * chore(appsync-dart-visitor): improve indexes generate following Dart lint rules * feat(appsync-dart-visitor): generate custom PK supporting code * Make custom PK fields immutable in copyWidth function * Improve ModelIdentifier methods implementation * Use the feature flag to control custom PK impl generation * udpate snapshot for updated dart comment blocks * Improve generated model identifier helper class * Update existing unit test snapshots and add new tests for custom PK * Remove unnecesary new initiating instances * revert comment block changes * Update the impl getting identifier fields * Revert "Remove unnecesary new initiating instances" This reverts commit 38927cb. * Remove trash code...
* fix(appsync-dart-visitor): update broken test snapshot * chore(appsync-dart-visitor): improve indexes generate following Dart lint rules * feat(appsync-dart-visitor): generate custom PK supporting code * Make custom PK fields immutable in copyWidth function * Improve ModelIdentifier methods implementation * Use the feature flag to control custom PK impl generation * udpate snapshot for updated dart comment blocks * Improve generated model identifier helper class * Update existing unit test snapshots and add new tests for custom PK * Remove unnecesary new initiating instances * revert comment block changes * Update the impl getting identifier fields * Revert "Remove unnecesary new initiating instances" This reverts commit 38927cb. * Remove trash code...
* fix(appsync-dart-visitor): update broken test snapshot * chore(appsync-dart-visitor): improve indexes generate following Dart lint rules * feat(appsync-dart-visitor): generate custom PK supporting code * Make custom PK fields immutable in copyWidth function * Improve ModelIdentifier methods implementation * Use the feature flag to control custom PK impl generation * udpate snapshot for updated dart comment blocks * Improve generated model identifier helper class * Update existing unit test snapshots and add new tests for custom PK * Remove unnecesary new initiating instances * revert comment block changes * Update the impl getting identifier fields * Revert "Remove unnecesary new initiating instances" This reverts commit 38927cb. * Remove trash code...
* fix(appsync-dart-visitor): update broken test snapshot * chore(appsync-dart-visitor): improve indexes generate following Dart lint rules * feat(appsync-dart-visitor): generate custom PK supporting code * Make custom PK fields immutable in copyWidth function * Improve ModelIdentifier methods implementation * Use the feature flag to control custom PK impl generation * udpate snapshot for updated dart comment blocks * Improve generated model identifier helper class * Update existing unit test snapshots and add new tests for custom PK * Remove unnecesary new initiating instances * revert comment block changes * Update the impl getting identifier fields * Revert "Remove unnecesary new initiating instances" This reverts commit 38927cb. * Remove trash code...
* fix(appsync-dart-visitor): update broken test snapshot * chore(appsync-dart-visitor): improve indexes generate following Dart lint rules * feat(appsync-dart-visitor): generate custom PK supporting code * Make custom PK fields immutable in copyWidth function * Improve ModelIdentifier methods implementation * Use the feature flag to control custom PK impl generation * udpate snapshot for updated dart comment blocks * Improve generated model identifier helper class * Update existing unit test snapshots and add new tests for custom PK * Remove unnecesary new initiating instances * revert comment block changes * Update the impl getting identifier fields * Revert "Remove unnecesary new initiating instances" This reverts commit 38927cb. * Remove trash code...
* fix(appsync-dart-visitor): update broken test snapshot * chore(appsync-dart-visitor): improve indexes generate following Dart lint rules * feat(appsync-dart-visitor): generate custom PK supporting code * Make custom PK fields immutable in copyWidth function * Improve ModelIdentifier methods implementation * Use the feature flag to control custom PK impl generation * udpate snapshot for updated dart comment blocks * Improve generated model identifier helper class * Update existing unit test snapshots and add new tests for custom PK * Remove unnecesary new initiating instances * revert comment block changes * Update the impl getting identifier fields * Revert "Remove unnecesary new initiating instances" This reverts commit 38927cb. * Remove trash code...
* fix(appsync-dart-visitor): update broken test snapshot * chore(appsync-dart-visitor): improve indexes generate following Dart lint rules * feat(appsync-dart-visitor): generate custom PK supporting code * Make custom PK fields immutable in copyWidth function * Improve ModelIdentifier methods implementation * Use the feature flag to control custom PK impl generation * udpate snapshot for updated dart comment blocks * Improve generated model identifier helper class * Update existing unit test snapshots and add new tests for custom PK * Remove unnecesary new initiating instances * revert comment block changes * Update the impl getting identifier fields * Revert "Remove unnecesary new initiating instances" This reverts commit 38927cb. * Remove trash code...
* fix(appsync-dart-visitor): update broken test snapshot * chore(appsync-dart-visitor): improve indexes generate following Dart lint rules * feat(appsync-dart-visitor): generate custom PK supporting code * Make custom PK fields immutable in copyWidth function * Improve ModelIdentifier methods implementation * Use the feature flag to control custom PK impl generation * udpate snapshot for updated dart comment blocks * Improve generated model identifier helper class * Update existing unit test snapshots and add new tests for custom PK * Remove unnecesary new initiating instances * revert comment block changes * Update the impl getting identifier fields * Revert "Remove unnecesary new initiating instances" This reverts commit 38927cb. * Remove trash code...
* fix(appsync-dart-visitor): update broken test snapshot * chore(appsync-dart-visitor): improve indexes generate following Dart lint rules * feat(appsync-dart-visitor): generate custom PK supporting code * Make custom PK fields immutable in copyWidth function * Improve ModelIdentifier methods implementation * Use the feature flag to control custom PK impl generation * udpate snapshot for updated dart comment blocks * Improve generated model identifier helper class * Update existing unit test snapshots and add new tests for custom PK * Remove unnecesary new initiating instances * revert comment block changes * Update the impl getting identifier fields * Revert "Remove unnecesary new initiating instances" This reverts commit 38927cb. * Remove trash code...
* fix(appsync-dart-visitor): update broken test snapshot * chore(appsync-dart-visitor): improve indexes generate following Dart lint rules * feat(appsync-dart-visitor): generate custom PK supporting code * Make custom PK fields immutable in copyWidth function * Improve ModelIdentifier methods implementation * Use the feature flag to control custom PK impl generation * udpate snapshot for updated dart comment blocks * Improve generated model identifier helper class * Update existing unit test snapshots and add new tests for custom PK * Remove unnecesary new initiating instances * revert comment block changes * Update the impl getting identifier fields * Revert "Remove unnecesary new initiating instances" This reverts commit 38927cb. * Remove trash code...
* feat(appsync-dart-visitor): attach index info to model schema (#391) * Chore/custom pk flutter (#393) * Revert "fix: revert custom pk change (#376)" This reverts commit fa4fe52. * feat: change model meta generation in models * feat: add useCustomPrimaryKey ff * fix: rm unused import * rebase master Co-authored-by: Zeyu Li <[email protected]> * Feat/custom pk flutter impl (#394) * fix(appsync-dart-visitor): update broken test snapshot * chore(appsync-dart-visitor): improve indexes generate following Dart lint rules * feat(appsync-dart-visitor): generate custom PK supporting code * Make custom PK fields immutable in copyWidth function * Improve ModelIdentifier methods implementation * Use the feature flag to control custom PK impl generation * udpate snapshot for updated dart comment blocks * Improve generated model identifier helper class * Update existing unit test snapshots and add new tests for custom PK * Remove unnecesary new initiating instances * revert comment block changes * Update the impl getting identifier fields * Revert "Remove unnecesary new initiating instances" This reverts commit 38927cb. * Remove trash code... * Add method override annotation (#402) * Custom pk flutter merge main (#407) * feat: update imports generated for flutter datastore plugin dependency (#382) (#388) * chore(amplify-codegen): change flutter import path from datastore to core (#380) * feat(appsync-modelgen-plugin): Change flutter datastore models dependency to use amplify_core * feat(appsync-modelgen-plugin): add amplify_flutter version check to determine datastore dependency import * fix(appsync-modelgen-plugin): correct indentation for error message * fix(appsync-modelgen-plugin): run linter * fix(amplify-codegen): update unit tests * fix(amplify-codegen): lower minimum version to 0.4.0-rc.1 * fix(appsync-modelgen-plugin): remove duplicate .dart from imports Co-authored-by: Travis Sheppard <[email protected]> Co-authored-by: Dane Pilcher <[email protected]> Co-authored-by: Phani Srikar Edupuganti <[email protected]> Co-authored-by: Travis Sheppard <[email protected]> * chore(release): Publish [ci skip] - [email protected] - @aws-amplify/[email protected] * feat: add null type union to optional fields * chore(release): Publish [ci skip] - [email protected] - @aws-amplify/[email protected] * fix(appsync-dart-visitor): update ignored linter rules (#404) * fix(appsync-dart-visitor): update ignored linter rules * Dedupe * fix unit tests snapshot Co-authored-by: Dane Pilcher <[email protected]> Co-authored-by: Phani Srikar Edupuganti <[email protected]> Co-authored-by: Travis Sheppard <[email protected]> Co-authored-by: phani-srikar <[email protected]> Co-authored-by: yeung-wah <[email protected]> * rm unrelated changes * fix: unit tests for non model * feat: add custom pk connected model support for belongsTo * fix: lint error * lgtm error * fix snapshot after rebase * feat: add support for hasMany CPK * fix: snapshots * fix: hasone associate with key * fix: add PK field type respect * feat(appsync-dart-visitor): capability of creating query predicate wi… (#441) * feat(appsync-dart-visitor): capability of creating query predicate with custom PK * wrap the code generation with the feature flag * fix: snapshots * fix: change unit test Co-authored-by: Hui Zhao <[email protected]> Co-authored-by: Dane Pilcher <[email protected]> Co-authored-by: Phani Srikar Edupuganti <[email protected]> Co-authored-by: Travis Sheppard <[email protected]> Co-authored-by: phani-srikar <[email protected]> Co-authored-by: yeung-wah <[email protected]>
* feat(modelgen):custom pk support for all platforms * feat(modelgen): connected model support for custom pk (#430) * feat(modelgen): connected model support for custom pk * remove additional code * remove additional code * use neat statements for targetName * fix: manyToMany pk issue * fix: distinguish between option id and custom id * feat: add associateWithFields and model fk fields * fix: adding fields in belongsTo * feat: add associatedWithFields to support CPK * fix lint error * fix: rm error for fields in belongsTo * fix: rewrite toCamelCase, manyToMany and belongsTo process * feat: refactor hasOne process * feat: add PK/SK original field respect * fix: move constants and remove id type error * fix: refactor get connected fields for hasOne and belongsTo * add unit tests for connected fields refactor * fix: import * address CRs * fix: change pk naming in manyToMany models (#455) * address CRs * feat(modelgen-java): custom PK support for android (#422) * fix: remove id generation when custom pk is defined * add primary key class generation * add model config * add import for model primary key * add resolveIdentifier and pk class field * use outer class for pk class * fix: lgtm alert * address feedback * move pk class to nested one * rename primary key to identifier * feat: add target names for hasone/belongsTo * update snapshot * fix lint issue * fix: change version from string to int * always generate targetName field * fix: add fk fields in models * feat: add hasmany cpk support * fix: snapshot * fix: hasOne associateWith issue * fix: add PK field type respect * fix: apply feature flag to CPK java code * fix lint * fix: snapshots * fix: pre-define booleans for backward compatability * change ff condition * feat(modelgen-swift): custom primary key support for ios (#425) * fix: remove id generation when custom pk is defined * feat: add custom pk support for ios * fix snapshots * add empty line * fix: pk related fields to immutable * feat: add target names in hasOne/belongsTo model * rm additional parenthesis * feat: add hasMany connected model CPK support * fix: snapshot * fix: hasOne asscociate with key * fix: update ff name * fix: use feature flag for swift CPK * fix: snapshot * fix lint * add ff check * feat(modelgen-js): custom primary key support (#389) * Revert "fix: revert custom pk change (#376)" This reverts commit fa4fe52. * feat: change model meta generation in models * feat: add useCustomPrimaryKey ff * fix: rm unused import * rebase master * fix: add composite identifier type * fix: use codegen field for sortKeyField * fix: change ff name and set to true for test purpose * fix: composite key for id with sk * add targetNames in schema * add target name fields in model * add associateWithFields meta for hasOne relation * feat: add hasMany CPK support * fix: additional fiels in hasmany belongsTo * fix: associate with key issue * fix: use iscustomPK enabled * fix: update PK field respect * fix: meta snap * feat(modelgen-dart): custom pk support for flutter (#428) * feat(appsync-dart-visitor): attach index info to model schema (#391) * Chore/custom pk flutter (#393) * Revert "fix: revert custom pk change (#376)" This reverts commit fa4fe52. * feat: change model meta generation in models * feat: add useCustomPrimaryKey ff * fix: rm unused import * rebase master Co-authored-by: Zeyu Li <[email protected]> * Feat/custom pk flutter impl (#394) * fix(appsync-dart-visitor): update broken test snapshot * chore(appsync-dart-visitor): improve indexes generate following Dart lint rules * feat(appsync-dart-visitor): generate custom PK supporting code * Make custom PK fields immutable in copyWidth function * Improve ModelIdentifier methods implementation * Use the feature flag to control custom PK impl generation * udpate snapshot for updated dart comment blocks * Improve generated model identifier helper class * Update existing unit test snapshots and add new tests for custom PK * Remove unnecesary new initiating instances * revert comment block changes * Update the impl getting identifier fields * Revert "Remove unnecesary new initiating instances" This reverts commit 38927cb. * Remove trash code... * Add method override annotation (#402) * Custom pk flutter merge main (#407) * feat: update imports generated for flutter datastore plugin dependency (#382) (#388) * chore(amplify-codegen): change flutter import path from datastore to core (#380) * feat(appsync-modelgen-plugin): Change flutter datastore models dependency to use amplify_core * feat(appsync-modelgen-plugin): add amplify_flutter version check to determine datastore dependency import * fix(appsync-modelgen-plugin): correct indentation for error message * fix(appsync-modelgen-plugin): run linter * fix(amplify-codegen): update unit tests * fix(amplify-codegen): lower minimum version to 0.4.0-rc.1 * fix(appsync-modelgen-plugin): remove duplicate .dart from imports Co-authored-by: Travis Sheppard <[email protected]> Co-authored-by: Dane Pilcher <[email protected]> Co-authored-by: Phani Srikar Edupuganti <[email protected]> Co-authored-by: Travis Sheppard <[email protected]> * chore(release): Publish [ci skip] - [email protected] - @aws-amplify/[email protected] * feat: add null type union to optional fields * chore(release): Publish [ci skip] - [email protected] - @aws-amplify/[email protected] * fix(appsync-dart-visitor): update ignored linter rules (#404) * fix(appsync-dart-visitor): update ignored linter rules * Dedupe * fix unit tests snapshot Co-authored-by: Dane Pilcher <[email protected]> Co-authored-by: Phani Srikar Edupuganti <[email protected]> Co-authored-by: Travis Sheppard <[email protected]> Co-authored-by: phani-srikar <[email protected]> Co-authored-by: yeung-wah <[email protected]> * rm unrelated changes * fix: unit tests for non model * feat: add custom pk connected model support for belongsTo * fix: lint error * lgtm error * fix snapshot after rebase * feat: add support for hasMany CPK * fix: snapshots * fix: hasone associate with key * fix: add PK field type respect * feat(appsync-dart-visitor): capability of creating query predicate wi… (#441) * feat(appsync-dart-visitor): capability of creating query predicate with custom PK * wrap the code generation with the feature flag * fix: snapshots * fix: change unit test Co-authored-by: Hui Zhao <[email protected]> Co-authored-by: Dane Pilcher <[email protected]> Co-authored-by: Phani Srikar Edupuganti <[email protected]> Co-authored-by: Travis Sheppard <[email protected]> Co-authored-by: phani-srikar <[email protected]> Co-authored-by: yeung-wah <[email protected]> * fix: use read ff to replace hardcode Co-authored-by: Hui Zhao <[email protected]> Co-authored-by: Dane Pilcher <[email protected]> Co-authored-by: Phani Srikar Edupuganti <[email protected]> Co-authored-by: Travis Sheppard <[email protected]> Co-authored-by: phani-srikar <[email protected]> Co-authored-by: yeung-wah <[email protected]>
Description of changes
Issue #, if available
aws-amplify/amplify-flutter#1426
Description of how you validated changes
Sample of generate model with a custom PK
SchemaGenerated Dart model
Checklist
yarn test
passesBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.