community.postgresql icon indicating copy to clipboard operation
community.postgresql copied to clipboard

have a `comment` argument wherever an object is created

Open hunleyd opened this issue 3 years ago • 3 comments

  From a user perspective I think it would be more convenient to have a `comment` argument wherever an object is created. To only change a comment, they need to be idempotent. At a quick glance, the argument would suit 11 modules:
  • [x] postgresql_db: #646
  • [x] postgresql_ext: #652
  • [ ] postgresql_idx
  • [x] ~~postgresql_lang~~ (deprecated)
  • [x] postgresql_publication: #654
  • [x] postgresql_schema: #650
  • [ ] postgresql_sequence
  • [x] postgresql_subscription: #655
  • [ ] postgresql_table
  • [x] postgresql_tablespace: #651
  • [x] postgresql_user: #649 (already had the feature, uses the shared function now)
  • [x] add the comment argument value to check_input(...), check across all the modules
  • [x] check reset functionality in all the modules except publication for consistency
  • [x] add check_mode + mogrify to set_comment, fix tests across all the modules where it makes sense

I'd say the benefit of a comment argument or postgresql_comment module over postgresql_query is that we can validate the kind of object which is commented, to avoid SQL injections. As this is part of the query syntax, not a variable, we cannot rely on psycopg2/3 variable escaping.

Originally posted by @betanummeric in https://github.com/ansible-collections/community.postgresql/discussions/352#discussioncomment-3834647

hunleyd avatar Oct 12 '22 12:10 hunleyd

the comment argument feels like a good thing to me, it must be idempotent, of course. it can be a shared class/function

hunleyd avatar Oct 12 '22 12:10 hunleyd

Working on it, will be updating the issue description along the way

Andersson007 avatar Dec 10 '23 12:12 Andersson007

thanks for all your efforts to get this work as far along as you did @Andersson007 !

now we just need someone to step up for the remaining three items in the description.

hunleyd avatar Dec 20 '23 14:12 hunleyd