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 structured data in PostgreSQL COMMENTs #3487

Open
salim-b opened this issue May 6, 2024 · 1 comment
Open

Support structured data in PostgreSQL COMMENTs #3487

salim-b opened this issue May 6, 2024 · 1 comment
Labels
idea Needs of discussion to become an enhancement, not ready for implementation

Comments

@salim-b
Copy link

salim-b commented May 6, 2024

Problem

PostgREST allows to specify additional metadata to document the offered RESTful API via PostgreSQL COMMENTs. Other tools also leverage PostgreSQL COMMENTs to specify additional metadata or configuration, e.g.

If one decides to use one of these tools in conjunction with PostgREST, conflicts arise, i.e. PostgREST won't ignore the above tags but include them in the generated OpenAPI description. The underlying problem could be summarized as the lack of a common standard to include structured data in PostgreSQL COMMENTs1.

Solution

In another discussion @wolfgangwalther suggested to

use a yaml front matter block to add metadata, while keeping the current openapi comments support backwards compatible

YAML headers seem powerful (e.g. multiple tools could read the same keys) and pragmatic at the same time (not too hard to parse and can be implemented in a backwards-compatible way), so other tools would hopefully add support for it, too. The author of pg_graphql already showed approval and would implement it. YAML headers would also allow to "hide" arbitrary data from PostgREST like the above @-tags by simply defining them inside the YAML header (under a key that has no meaning for PostgREST). In the end, the possible use cases go far beyond PostgREST – but PostgREST could lead the way!

Preliminary discussion

Further notes

Footnotes

  1. A web search did not reveal any kind of existing initiative to establish such a standard. Please correct me, if I missed something!

@salim-b salim-b changed the title Support structured data in PostgreSQL COMMENTS Support structured data in PostgreSQL COMMENTs May 6, 2024
@wolfgangwalther
Copy link
Member

A more principled approach to this problem would be to work towards a feature in PostgreSQL to support "namespaced comments". Those could work very similar to SECURITY LABEL FOR <provider> ON ..., which is very similar in syntax (and I think the underlying architecture) to COMMENT ON ....

If we had something like COMMENT FOR <tool> ON .. we'd be much better off, I think.

@wolfgangwalther wolfgangwalther added the idea Needs of discussion to become an enhancement, not ready for implementation label May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
idea Needs of discussion to become an enhancement, not ready for implementation
Development

No branches or pull requests

2 participants