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 |
| $$ LANGUAGE sql; | ||
|
|
||
| -- col_isnt_pk( schema, table, column ) | ||
| CREATE OR REPLACE FUNCTION col_isnt_pk ( NAME, NAME, NAME ) |
There was a problem hiding this comment.
Adding this means existing use of col_isnt_pk ( NAME, NAME, TEXT ) may no longer work unless or until users cast that final argument. IOW, this would fail:
SELECT col_isnt_pk( 'x', 'y', 'z');They'll have to instead use one of these two:
SELECT col_isnt_pk( 'x', 'y', 'z'::name);
SELECT col_isnt_pk( 'x', 'y', 'z'::text);Which will be confusing because the types don't really tell you much.
| ); | ||
|
|
||
| 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.
| SELECT col_is_pk( :table, :column, :description ); | ||
| SELECT col_is_pk( :table, :columns ); | ||
| SELECT col_is_pk( :schema, :table, :column, :description ); | ||
| SELECT col_is_pk( :schema, :table, :column ); |
There was a problem hiding this comment.
Because of this, please follow the example of functions like col_is_unique() and add a note like this for each function that may now have ambiguity:
If you omit the description for the 3-argument version, you'll need to cast
the table and column parameters to the `NAME` data type so that PostgreSQL
doesn't resolve the function name as a description. For example:
```sql
SELECT col_is_pk( 'myschema', 'sometable'::name, 'pk_name'::name );|
Also: Please use the 50/72 rule in the commit message. |
Sorry, don't know what this responds to. |
Added missing `schema, table, column[]` and `schema, table, column` variants of `col_isnt_pk()`, `col_is_fk()`, and `col_isnt_fk()`. Established a consistent overload order for `col_is_pk()`, `col_isnt_pk()`, `col_is_fk()`, `col_isnt_fk()`, and `col_is_unique()`.
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.