-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Conversation
QA Wolf here! As you write new code it's important that your test coverage is keeping up. |
if (!sdk.views.isV2(view) || helpers.views.isCalculationView(view)) { | ||
continue | ||
} |
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.
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.
if (!schema.field) { | ||
throw new HTTPError( | ||
`Calculation field "${name}" is missing a "field" property`, | ||
400 | ||
) | ||
} |
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.
This a separate problem I ran into accidentally. It would error previously, but the message was unhelpful. This just improves the error message.
const viewSchema = view.schema[fieldName] | ||
if (!helpers.views.isCalculationField(viewSchema) && !schema[fieldName]) { |
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.
This is the primary fix for the problem this PR addresses.
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.
LGTM - thanks for the comments explaining the changes!
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.