checks for comments, exclusion constraints, array set_eq, and rls#306
checks for comments, exclusion constraints, array set_eq, and rls#306dmfay wants to merge 3 commits intotheory:mainfrom
Conversation
theory
left a comment
There was a problem hiding this comment.
col_has_exclusion is very welcome, and I like the idea of testing comment contents. The array comparison function seems superfluous, though.
Would you add tests for all of the few functions too, please? Will need to ensure they work across all supported OSes and Postgres versions; the automated testing workflow does that.
Thanks, love seeing new stuff here!
| Test whether [row-level security](https://www.postgresql.org/docs/current/ddl-rowsecurity.html) | ||
| is enabled (`:desired_value` true) or disabled (`:desired_value` false). |
There was a problem hiding this comment.
The description should go after the parameters to be consistent with the existing docs. Same goes for some of the other documentation added here.
| -- col_has_exclusion(schema, table, columns, description) | ||
| CREATE OR REPLACE FUNCTION col_has_exclusion(TEXT, TEXT, TEXT[], TEXT) | ||
| RETURNS TEXT AS $$ | ||
| SELECT ok(array_agg(attr.attname)::TEXT[] @> $3 AND $3 @> array_agg(attr.attname)::TEXT[]) |
There was a problem hiding this comment.
Looks like the @> operator will work on Postgres 9.1. Would you add tests for these new functions?
| -- set_eq( array, array, description ) | ||
| CREATE OR REPLACE FUNCTION set_eq(anyarray, anyarray, TEXT) | ||
| RETURNS TEXT AS $$ | ||
| SELECT ok($1 @> $2 AND $2 @> $1, $3); |
There was a problem hiding this comment.
This seems superfluous. Why not just use is(array1, array2)?
There was a problem hiding this comment.
is(a1, a2) is order-dependent but the order of our arrays is not guaranteed. Is there something else that would suit, short of unnesting both sides?
There was a problem hiding this comment.
Oh, I hadn't thought of that, of course! I like it! Would be useful to have something in the docs that talks about that difference.
| $$ LANGUAGE sql; | ||
|
|
||
| -- table_comment_has(schema, table, comment, description) | ||
| CREATE OR REPLACE FUNCTION table_comment_has(TEXT, TEXT, TEXT, TEXT) |
There was a problem hiding this comment.
WE use _has more to indicate that a database has an object, like a table. I think a better term to use here would be _contains. Or perhaps _matches and use a regular expression? That could help avoid variations in line endings across platforms.
Co-authored-by: David E. Wheeler <46604+theory@users.noreply.github.com>
|
@dmfay I've found this PR just before starting to work on some functions to check comments, what are your intention about this one ? |
I have not been able to prioritize working on this and this is on track to continue for the foreseeable future. If you'd like to use the comment functions in whole or in part please be my guest! |
|
Hi, what's the status of this PR? Is it ready for review? |
hello! We've added a few checks at Beacon:
set_eqThere are a few gaps (e.g. single-column exclusion constraints still have to be provided as an array) but if these are good for inclusion I can always add the overloads. What else needs to happen?