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

Fix table updates wiping out view calculation fields. #14756

Merged
merged 2 commits into from
Oct 10, 2024

Conversation

samwho
Copy link
Collaborator

@samwho samwho commented Oct 10, 2024

Description

Fixes another problem @aptkingston ran into: when updating a table, all of the view schemas are synced with the table. This would remove any field in the view not found in the table schema. I've added a check for calculation fields in there.

@samwho samwho requested a review from a team as a code owner October 10, 2024 10:51
@samwho samwho requested review from mike12345567 and removed request for a team October 10, 2024 10:51
Copy link

qa-wolf bot commented Oct 10, 2024

QA Wolf here! As you write new code it's important that your test coverage is keeping up.
Click here to request test coverage for this PR!

@github-actions github-actions bot added firestorm Data/Infra/Revenue Team size/m labels Oct 10, 2024
Comment on lines +34 to +36
if (!sdk.views.isV2(view) || helpers.views.isCalculationView(view)) {
continue
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is the only meaningful change in here, but I did a little refactoring to reduce the nesting and make this more readable while I was here.

Comment on lines +99 to +104
if (!schema.field) {
throw new HTTPError(
`Calculation field "${name}" is missing a "field" property`,
400
)
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This a separate problem I ran into accidentally. It would error previously, but the message was unhelpful. This just improves the error message.

Comment on lines +381 to +382
const viewSchema = view.schema[fieldName]
if (!helpers.views.isCalculationField(viewSchema) && !schema[fieldName]) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is the primary fix for the problem this PR addresses.

Copy link
Collaborator

@mike12345567 mike12345567 left a comment

Choose a reason for hiding this comment

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

LGTM - thanks for the comments explaining the changes!

Base automatically changed from view-calculation-filtering to master October 10, 2024 11:15
@samwho samwho enabled auto-merge October 10, 2024 11:20
@samwho samwho merged commit d9b6d5d into master Oct 10, 2024
12 checks passed
@samwho samwho deleted the view-calculation-fix-table-update branch October 10, 2024 11:31
@github-actions github-actions bot locked and limited conversation to collaborators Oct 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
firestorm Data/Infra/Revenue Team size/m
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants