-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
🪟 🎉 Clear user-defined primary key(s) and cursor field(s) if the field is removed #20203
Conversation
airbyte-webapp/src/views/Connection/ConnectionForm/calculateInitialCatalog.ts
Outdated
Show resolved
Hide resolved
airbyte-webapp/src/views/Connection/ConnectionForm/calculateInitialCatalog.ts
Outdated
Show resolved
Hide resolved
if (streamNode.config?.primaryKey && removedFieldPaths?.length) { | ||
// if any of the field paths in the primary key match any of the field paths that were removed, clear the entire primaryKey property | ||
if ( | ||
streamNode.config.primaryKey.some((key) => removedFieldPaths.some((removedPath) => isEqual(key, removedPath))) |
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.
it's possible that lodash intersection could tidy this up, but i haven't figured out how
} | ||
|
||
// if the stream is new since a refresh, verify cursor and get optimal sync modes | ||
const isStreamNew = newStreamDescriptors?.some( |
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.
no changes to this logic, just cleaning up some naming here for clarity
airbyte-webapp/src/views/Connection/ConnectionForm/calculateInitialCatalog.test.ts
Outdated
Show resolved
Hide resolved
: []; | ||
|
||
// if we're in edit or readonly mode and the stream is not new, check for breaking changes then return | ||
if (isNotCreateMode && !isStreamNew) { |
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.
I don't love that this check happens on readonly
connections. Presumably readonly
connections wouldn't ever have a breaking change so should return immediately when clearBreakingFieldChanges()
is called. It's not the only place we're doing something like this. I have proposed some cleanup in #20233.
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.
Discussed this with @tealjulia over Slack. We agree that it could be improved but it would require a lot of work outside of the scope of solving the current problem.
: []; | ||
|
||
// if we're in edit or readonly mode and the stream is not new, check for breaking changes then return | ||
if (isNotCreateMode && !isStreamNew) { |
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.
Discussed this with @tealjulia over Slack. We agree that it could be improved but it would require a lot of work outside of the scope of solving the current problem.
airbyte-webapp/src/views/Connection/ConnectionForm/formConfig.tsx
Outdated
Show resolved
Hide resolved
airbyte-webapp/src/views/Connection/ConnectionForm/calculateInitialCatalog.ts
Outdated
Show resolved
Hide resolved
airbyte-webapp/src/views/Connection/ConnectionForm/calculateInitialCatalog.ts
Show resolved
Hide resolved
airbyte-webapp/src/views/Connection/ConnectionForm/calculateInitialCatalog.ts
Show resolved
Hide resolved
airbyte-webapp/src/views/Connection/ConnectionForm/calculateInitialCatalog.ts
Outdated
Show resolved
Hide resolved
airbyte-webapp/src/views/Connection/ConnectionForm/calculateInitialCatalog.ts
Outdated
Show resolved
Hide resolved
…itialCatalog.ts Co-authored-by: Krishna (kc) Glick <krishna@airbyte.io>
…itialCatalog.ts Co-authored-by: Krishna (kc) Glick <krishna@airbyte.io>
What
closes #19387
Clears the primary key and/or cursor properties on the
stream.config
object if any of the fields referenced there are removed during a refresh.How
useInitialValues
(informConfig
) identifies if there is a breaking change on the connection. If there is, it will traverse the diff and pull out the transforms for the field(s) that were removedcalculateInitialValues
which is already used to calculate and override config fieldsRecommended reading order
calculateInitialCatalog.test.tsx
(for expected behaviors)formConfig.tsx
calculateInitialCatalog.ts
Testing
This is not behind the feature flag, but should not affect anything negatively. Open to discussion if we'd rather keep it behind the flag. Either way, useful to test both with
REACT_APP_AUTO_DETECT_SCHEMA_CHANGES
as true and as falseAt bare minimum:
These are also covered by unit tests.
Next steps
These files are due for a refactor.