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

prevent the cursor or primary key fields from being deselected #20481

Merged
merged 2 commits into from
Dec 14, 2022

Conversation

mfsiega-airbyte
Copy link
Contributor

What

Ensure that the cursor and primary key fields can't be deselected.

We might want to allow this in some cases, but for simplicity we disallow it entirely per the PRD.

How

If but cursor/primary key and selectedFields are provided, check that the key field is included in the list of selected fields.

@mfsiega-airbyte mfsiega-airbyte temporarily deployed to more-secrets December 14, 2022 15:57 — with GitHub Actions Inactive
@mfsiega-airbyte mfsiega-airbyte temporarily deployed to more-secrets December 14, 2022 15:57 — with GitHub Actions Inactive
Copy link
Contributor

@pmossman pmossman left a comment

Choose a reason for hiding this comment

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

Looks reasonable to me!

// TODO(mfsiega-airbyte): we only check the top level of the cursor/primary key fields because we
// don't support filtering nested fields yet.
if (!selectedFieldNames.contains(config.getCursorField().get(0))) {
throw new JsonValidationException("Cursor field cannot be de-selected");
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm trying to think if there could be a case where a non-cursor field shares a top-level key with a cursor field, and therefore can't be de-selected. Even if that is the case, probably better to merge this as-is for now because we're planning on adding support for nested fields relatively soon anyways

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah as it is today we only allow selecting top-level fields (which implies all of the children) - so the only way to deselect that non-cursor-field-which-shares-a-top-level-key-with-a-cursor is to deselect the top-level field, which in turn deselects the cursor...

But indeed we should support nested fields soon, at least on the backend.

Copy link
Contributor

Choose a reason for hiding this comment

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

Cool, makes sense to me, thanks for confirming!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/platform issues related to the platform area/server
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants