ckanext-validation icon indicating copy to clipboard operation
ckanext-validation copied to clipboard

Support foreign key validation

Open ChasNelson1990 opened this issue 2 years ago • 5 comments

Description

closes #84

Basically, I have rewritten _validate_table to use the frictionless Package object, instead of the Resource object.

This allows us to then pass in multiple resources and do the following:

  • if "foreignKeys" is in the schema we collect together `schema["foreignKeys"][i]["reference"]["resource"]
  • we go through and check if the referenced resource is a url (path), json object (data) or (the fall back) is a resource name that can be found within this ckan dataset; if none are true then we return a ValidationError
  • these can be added to our Package object for frictionless framework to utilise during validation

Testing

TODO - I am working on these.

Documentation

I have updated the documentation to explain how to use foreign keys. It's fairly brief at the moment but probably in line with other similar parts.

ChasNelson1990 avatar May 24 '23 11:05 ChasNelson1990

I think the lint failure is kinda incorrect - the lint Action is using Python 3.7.16 (which, as flake8 is saying, did not have the walrus operator); however, the minimum Python version for ckan with Python 3 is 3.8 (as documented here: https://docs.ckan.org/en/2.10/maintaining/installing/install-from-source.html) and Python 3.8 introduced the walrus operator.

So I have pushed a small commit to this branch that brings the lint GitHub Action in line with the CKAN-chosen python version 3.8. I have tested locally using act (using the nektos/act-environments-ubuntu:18.04 image) as I don't have the permissions to dispatch on Github.

ChasNelson1990 avatar Jun 05 '23 15:06 ChasNelson1990

@amercader - I appreciate you haven't had chance to review this yet but I was wondering if you could approve the workflow so that I can check my lint action change is fully working? Thanks!

ChasNelson1990 avatar Jun 15 '23 09:06 ChasNelson1990