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

WIP : Fix 1633 unexpected key error with primary key in schema #1640

Conversation

amelie-rondot
Copy link
Contributor

@amelie-rondot amelie-rondot commented Feb 10, 2024


This PR fix unexpected KeyError raised when a primary key used in shema is missing in the tabular data to validate.
For example:

data = [["B"], ["b"]]
schema = {
        "$schema": "https://frictionlessdata.io/schemas/table-schema.json",
        "fields": [
            {"name": "A"},
            {"name": "B"}
        ],
        "primaryKey": ["A"]
    }

This PR adds some test cases:

  • two test cases to ensure that when a label related to the schema primary key is missing, the validation report is invalid with single missing-label error:
    • a test case with the schema containing the primary key field not specified as 'required'
    • a test case with the schema containing the primary key field specified as 'required'
  • a test case to deal with insensitivity case in the data label corresponding to the primary key schema field: the validation report is valid

NB: to deal with insensitivity case, this PR should be rebased the branch related to this PR

Through this PR, I also suggest a refactoring to introduce intermediary TableResource methods to create cells related to primary key schema.

…o a required field and primary key schema: test fails
…l error when missing label corresponding to a schema primary key: test fails
…imary key constraint and considering case-sensitivity
@amelie-rondot
Copy link
Contributor Author

This PR is replaced by PR#1641

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

KeyError when a "primaryKey" is missing
1 participant