Skip to content
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

Define models needed for HPC-7904 #30

Merged
merged 16 commits into from
Nov 3, 2021
Merged

Define models needed for HPC-7904 #30

merged 16 commits into from
Nov 3, 2021

Conversation

Pl217
Copy link
Contributor

@Pl217 Pl217 commented Nov 2, 2021

There are a few changes I would request in #29, but it got already merged, so I made them here. Didn't want to open a new PR.

Took the opportunity to update Typescript, since I also updated it in UN-OCHA/hpc-api#21.

Version bump is also done, because we'll need to do a release after this is merged, so that separate PR for version bump is not needed.

@Pl217 Pl217 added the pending prior merge Another Pull Request needs to be merged before this one label Nov 2, 2021
@Pl217 Pl217 assigned s0 Nov 2, 2021
@Pl217 Pl217 requested a review from a team as a code owner November 2, 2021 10:21
@s0 s0 assigned czmj and unassigned s0 Nov 2, 2021
@Pl217 Pl217 added ready for review All comments have been addressed, and the Pull Request is ready for review and removed pending prior merge Another Pull Request needs to be merged before this one labels Nov 2, 2021
@Pl217 Pl217 assigned s0 Nov 2, 2021
@Pl217
Copy link
Contributor Author

Pl217 commented Nov 2, 2021

@s0 I would also like you to take a look, since I've made some changes to models defined in #29.
Also, some changes are relevant to my review in https://github.com/UN-OCHA/hpc_service/pull/2467

planId column is marked as NULL-able, but there are
zero records in DB withouth this column set
This column is marked as NULL-able, and there are
records already which have NULL set for this column.
This column is NULL-able with a DEFAULT value
specified to be empty array.

But, seems this DEFAULT value wasn't always
set, since there are records with NULL value
for this column.
This column is defined with `overriding boolean DEFAULT false NOT NULL`
which clearly qualifies it to be marked as nonNullWithDefault
These two columns are defined as NULL-able and already
have records with NULL values for these columns
Copy link
Contributor

@s0 s0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 minor changes need to be done. I'll do it quickly myself though as i'd like to get this in and have just reviewed

Comment on lines 40 to 43
status: {
kind: 'enum',
values: LOCATION_STATUS,
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enum should only be used when the property uses an enum defined in sql, this particular field is a string, so instead we should use a checked string with t.keyof to validate upon read, and restrict the type when writing.

The reason for this is that at some point I'd like to extend the validation function / unit tests to check that enum types are defined correctly, and allow the same values.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense even now, without enum definition checks

Comment on lines 47 to 51
// Even though this column isn't defined using DB enum only two values are used
clusterSelectionType: {
kind: 'enum',
values: PLAN_VERSION_CLUSTER_SELECTION_TYPE,
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should use a checked t.keyof type instead

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should have removed this comment above too. Since it "justifies" why 'enum' was used

@s0 s0 merged commit 868d333 into develop Nov 3, 2021
@s0 s0 deleted the HPC-7904-models branch November 3, 2021 10:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready for review All comments have been addressed, and the Pull Request is ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants