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

add has_comment() #322

Open
kbrannen opened this issue Sep 25, 2023 · 3 comments
Open

add has_comment() #322

kbrannen opened this issue Sep 25, 2023 · 3 comments

Comments

@kbrannen
Copy link

This is probably incredibly low on the priority list, but it just occurred to me that there is no has_comment() function. I don't think we need hasnt_comment(), but it could be done if it was simple as doing "select not has_comment(...)".

There are 2 paths to take on this if done:

  1. has_comment(name, type [,comment] [,description]) -- where type is database, schema, function, table, ...
  2. has_db_comment(), has_schema_comment(), has_function_comment(), ...

It gets a little crazy because just about every type of object can have a comment. I think I'd rather do 1 to avoid a proliferation of functions.

I'm not sure if we want to check if the object simply has a comment which would be "has_comment()", or if we'd care about know that the comment value is what we expect which I think would work better with "comment_is()". Or do we need both? :)

You can see the comments by adding "+" to almost any command in psql, e.g. \l+, \dt+, \d+, \dn+, etc. The comment will show in the "Description" column. The value gets there with the command COMMENT ON {object} {name} IS '{description}'; hence has_comment() but I suppose we could call it has_description().

@rodo
Copy link
Contributor

rodo commented Sep 23, 2024

@theory what are your thoughts on this on the function naming ?

If the following seems ok for you ?

SELECT table_comment_is ( :schema, :table, :comment, :description );
SELECT table_comment_is ( :schema, :table, :comment );
SELECT table_comment_is ( :table, :comment, :description );
SELECT table_comment_is ( :table, :comment );
SELECT column_comment_is ( :schema, :table, :column, :comment, :description );
SELECT column_comment_is ( :schema, :table, :column, :comment );
SELECT column_comment_is ( :table, :column, :comment, :description );
SELECT column_comment_is ( :table, :column, :comment );

And so on for other objects ?

@theory
Copy link
Owner

theory commented Sep 23, 2024

Yeah, that looks like other stuff we have now.

@rodo
Copy link
Contributor

rodo commented Sep 24, 2024

Done in #306

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants