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

Not require foreignKey.reference.resource for self-referencing #29

Merged
merged 12 commits into from
Mar 19, 2024

Conversation

roll
Copy link
Member

@roll roll commented Feb 5, 2024

Copy link

cloudflare-pages bot commented Feb 5, 2024

Deploying datapackage with  Cloudflare Pages  Cloudflare Pages

Latest commit: 8a18a48
Status: ✅  Deploy successful!
Preview URL: https://5cc2e3f9.datapackage.pages.dev
Branch Preview URL: https://878-simplify-fk-self-referen.datapackage.pages.dev

View logs

@peterdesmet
Copy link
Member

Why not always require resource? Even if it is self-referencing.

@roll
Copy link
Member Author

roll commented Feb 12, 2024

@peterdesmet
In my opinion, requiring resource: "" is quite weird and error-prone (empty string is falsy in majority of languages). At least it would make mor sense for me if it were something like resource: "self"

@peterdesmet
Copy link
Member

I was suggesting to have the resource name, even for an internal relationship. So for a resource called events:

"foreignKeys": [
    {
      "fields": "parentEventID",
      "reference": {
        "resource": "events", <-- Not "" or "self", just the resource name
        "fields": "eventID"
      }
    }
  ]

@roll
Copy link
Member Author

roll commented Feb 12, 2024

@peterdesmet
That's pretty eloquent. I would support this

@khusmann
Copy link
Contributor

I really like @peterdesmet 's self-referencing approach, but what do we do if it is a standalone schema definition (i.e. defined in a json outside of a datapackage)? We could encounter the situation where two resources of different names to point to the same external schema...

That said, I think this is more an argument against external schemas, rather than this approach to foreignKey.reference.resource. I've never liked externally loaded schemas because it means it a web request is potentially required to get the field structure of a resource definition to parse local data... (and the remote definition could change or go offline, rendering the local data unusable!) I think this issue with foreignKey.reference.resource points to another example of why it'd good to require schemas to be statically bundled with resource definitions, rather than externally linked.

@roll
Copy link
Member Author

roll commented Feb 20, 2024

VETOED by WG

I'll create an updated PR based on @peterdesmet's solution

@roll roll closed this Feb 20, 2024
@roll roll reopened this Feb 21, 2024
@roll
Copy link
Member Author

roll commented Feb 21, 2024

Let's have one last try here according to this comment - #37 (comment)

@peterdesmet
Copy link
Member

Let's have one last try here according to this comment - #37 (comment)

I'm sorry to reopen the discussion. 😄 Can you adapt this PR? The spec indeed removes the requirement, but the text currently uses "self".

@roll
Copy link
Member Author

roll commented Feb 21, 2024

@peterdesmet
Oops I used the same branch. Thanks! It's been fixed now

@roll
Copy link
Member Author

roll commented Mar 11, 2024

@peterdesmet
Can you please re-vote if I got you right 😃

@roll
Copy link
Member Author

roll commented Mar 11, 2024

@pschumm
@pwalsh
@nichtich
Can you please take a look at this PR?

@roll roll added the candidate label Mar 11, 2024
@peterdesmet
Copy link
Member

@roll I approve this PR.

@roll
Copy link
Member Author

roll commented Mar 14, 2024

Thanks @peterdesmet !

@pschumm
Copy link

pschumm commented Mar 14, 2024

Looks good to me.

@roll
Copy link
Member Author

roll commented Mar 18, 2024

Thanks!

We miss one vote now. @khughitt @PietrH would you consider supporting it?

@khughitt
Copy link

Change looks good to me!

@roll
Copy link
Member Author

roll commented Mar 19, 2024

Thanks!

ACCEPTED by WG (6/9)

@roll roll merged commit 74d7752 into main Mar 19, 2024
1 check passed
@roll roll deleted the 878/simplify-fk-self-referencing branch March 19, 2024 08:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow omitting foreignKey.reference.resource for self-referencing
5 participants