-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,6 +97,13 @@ async function guardCalculationViewSchema( | |
continue | ||
} | ||
|
||
if (!schema.field) { | ||
throw new HTTPError( | ||
`Calculation field "${name}" is missing a "field" property`, | ||
400 | ||
) | ||
} | ||
Comment on lines
+100
to
+105
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 targetSchema = table.schema[schema.field] | ||
if (!targetSchema) { | ||
throw new HTTPError( | ||
|
@@ -377,7 +384,8 @@ export function syncSchema( | |
|
||
if (view.schema) { | ||
for (const fieldName of Object.keys(view.schema)) { | ||
if (!schema[fieldName]) { | ||
const viewSchema = view.schema[fieldName] | ||
if (!helpers.views.isCalculationField(viewSchema) && !schema[fieldName]) { | ||
Comment on lines
+387
to
+388
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the primary fix for the problem this PR addresses. |
||
delete view.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 only meaningful change in here, but I did a little refactoring to reduce the nesting and make this more readable while I was here.