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

Support foreign key checks #88

Merged
merged 16 commits into from
Aug 29, 2017
Merged

Support foreign key checks #88

merged 16 commits into from
Aug 29, 2017

Conversation

roll
Copy link
Member

@roll roll commented Aug 23, 2017


On tableschema level we just accepts references argument for Table constructor. It's because tableschema layer is not responsible for integrity checks by itself but provides tools for it like schema.foreignKeys and table FK checks if references is passed.

So on datapackage level those references should be composed. See this PR tests and readme diff for more references argument information. See datapackage implementation - frictionlessdata/datapackage-js#89

@roll roll added the review label Aug 23, 2017
@roll roll changed the title [WIP] Support foreign key checks Support foreign key checks Aug 24, 2017
@roll roll requested a review from amercader August 24, 2017 08:42
@roll
Copy link
Member Author

roll commented Aug 24, 2017

@amercader
Could you please review?

Copy link
Member

@amercader amercader left a comment

Choose a reason for hiding this comment

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

+1

['id', 'height', 'age', 'name', 'occupation'],
[1, 10.0, 1, 'string1', new Date(2012, 6-1, 15)]])
})
describe('#foreignKeys', () => {
Copy link
Member

Choose a reason for hiding this comment

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

Maybe add a test for self reference FK, as in the Python implementation? Can be done on a separate PR though.

Copy link
Member Author

Choose a reason for hiding this comment

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

We have for self-referencing in datapackage tests.

Copy link
Member

Choose a reason for hiding this comment

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

True, sorry I got the two mixed up!

@roll roll merged commit ded028d into master Aug 29, 2017
@roll roll deleted the fk-support branch August 29, 2017 14:31
@roll roll removed the review label Aug 29, 2017
@Stephen-Gates
Copy link

@roll thanks so much for this change. It really helps my project and your timing is perfect.

I'll think about the wording to use in spec.json for the new error message you added to support #86

@roll
Copy link
Member Author

roll commented Aug 30, 2017

@Stephen-Gates
I'll suggest fixing #86 on Aug 4 sprint planning.

@Stephen-Gates
Copy link

Stephen-Gates commented Aug 30, 2017

@roll here's my attempt at an error message.

message: The value {value} in row {row_number} and column {column_name_A} does not have a matching value in column {column_name_B} in table {table_name_B}

description: A matching value should exist for a valid foreign key relationship. How it could be resolved:

  • If this value is not correct, update the value.
  • If value is correct, then add it to column {column_name_B} in table {table_name_B}
  • If this error should be ignored, then disable the foreign key check for column {column_name_A}

Not sure if the last dot point is needed - just conforming with format of other messages.

@roll
Copy link
Member Author

roll commented Aug 31, 2017

@Stephen-Gates
Thanks! I've add it to #86

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.

None yet

3 participants