Improved col_is{nt}_X implementation - #369
Conversation
No, I think it's the same, it's just named differently because SQL has a |
|
@theory Understood, I'll conform it right now, one moment |
| ); | ||
|
|
||
| SELECT * FROM check_test( | ||
| col_is_fk( 'public', 'fk', 'pk_id'::name ), |
There was a problem hiding this comment.
Oh, so the existing tests, which don't cast the third argument, still pass? Okay then it seems like it will be backward compatible after all.
|
Also: Please use the 50/72 rule in the commit message. |
Sorry, don't know what this responds to. |
|
Please rebase onto main and squash down to a single commit. Thanks. |
f2ac65c to
1f71852
Compare
|
@theory |
Add schema-qualified overloads for column primary key and foreign key assertions, and establish a consistent function order. Add `col_isnt_unique()` with matching documentation and tests. Standardize array-argument comments to use `columns[]`.
|
@theory |
| -- col_is_pk( schema, table, column[] ) | ||
| CREATE OR REPLACE FUNCTION col_is_pk ( NAME, NAME, NAME[] ) | ||
| RETURNS TEXT AS $$ | ||
| SELECT col_is_pk( $1, $2, $3, 'Columns ' || quote_ident($1) || '.' || quote_ident($2) || '(' || _ident_array_to_string($3, ', ') || ') should be a primary key' ); | ||
| $$ LANGUAGE sql; | ||
|
|
||
| -- col_is_pk( table, column[], description ) | ||
| CREATE OR REPLACE FUNCTION col_is_pk ( NAME, NAME[], TEXT ) | ||
| RETURNS TEXT AS $$ | ||
| SELECT is( _ckeys( $1, 'p' ), $2, $3 ); | ||
| $$ LANGUAGE sql; | ||
|
|
||
| -- col_is_pk( table, column[] ) | ||
| CREATE OR REPLACE FUNCTION col_is_pk ( NAME, NAME[] ) | ||
| RETURNS TEXT AS $$ | ||
| SELECT col_is_pk( $1, $2, 'Columns ' || quote_ident($1) || '(' || _ident_array_to_string($2, ', ') || ') should be a primary key' ); | ||
| $$ LANGUAGE sql; |
There was a problem hiding this comment.
Please do not move functions. It creates unnecessary churn in the PR and complicates maintenance of the compatibility patches.
| -- col_is_pk( table, columns[], description ) | ||
| CREATE OR REPLACE FUNCTION col_is_pk ( NAME, NAME[], TEXT ) | ||
| RETURNS TEXT AS $$ | ||
| SELECT is( _ckeys( $1, 'p' ), $2, $3 ); | ||
| $$ LANGUAGE sql; | ||
|
|
There was a problem hiding this comment.
Please put all the new functions together in contiguous lines.
Closes #363 [1/3]
As discussed this is the first part of the PR split -> implementation symmetry.
All 3 now follow:
EDIT:
col_is_nullisn't in scope because you went theis/notinstead ofis/isntso I didn't think it was pertinent. If you disagree I can conform it as well I suppose.