Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

OpenAPI does not tag a column as FK if it also has a UNIQUE constraint #3418

Closed
laurenceisla opened this issue Apr 18, 2024 · 2 comments · Fixed by #3419
Closed

OpenAPI does not tag a column as FK if it also has a UNIQUE constraint #3418

laurenceisla opened this issue Apr 18, 2024 · 2 comments · Fixed by #3419
Labels

Comments

@laurenceisla
Copy link
Member

Environment

  • PostgreSQL version: 15.6
  • PostgREST version: 12.0.2
  • Operating system: NixOS

Description of issue

When a Foreign Key column is detected, OpenAPI adds the description "Note: This is a Foreign Key..." to it. But if that column also has a UNIQUE constraint, then it does not show that description anymore, e.g.:

This column shows the message:

todo_id int references api.todos(id)

While this doesn't:

todo_id int references api.todos(id) unique
@softmarshmallow
Copy link

Hi @laurenceisla . I have a follow up question regards to this issue and PR

I've managed to parse the fk data, but still cannot tell if its a unique one. (if it returns non array)

Q: can we get a example description output when the fk is unique ?

Before:

"description": "Note:\nThis is a Foreign Key to `foreign.id`.<fk table='foreign' column='id'/>",

After:

?

Q: Is this a PR that I think it is? - I am trying to parse the one-to-one metadata, but since the properties does not contain additional metadata if it is uniqye other than if its a pk.

Is this issue answers my question or should I open a new issue for having unique metadata in description?

Thank you : )

@laurenceisla
Copy link
Member Author

@softmarshmallow

Is this a PR that I think it is?

The main issue was that the "Note: This is a Foreing Key...." message was not showing at all. You wouldn't know if it was a foreign key when it had UNIQUE.

... or should I open a new issue for having unique metadata in description?

So, yes, opening a new issue is better.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Development

Successfully merging a pull request may close this issue.

2 participants