-
Notifications
You must be signed in to change notification settings - Fork 103
WIP: Add procedures are()
#359
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
base: main
Are you sure you want to change the base?
Changes from all commits
f784e51
b897cb9
135a957
c3b7b24
2d876f6
2dcd43b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
-- procedures_are( schema, procedures[], description ) | ||
CREATE OR REPLACE FUNCTION procedures_are ( NAME, NAME[], TEXT ) | ||
RETURNS TEXT AS $$ | ||
SELECT _are( | ||
'procedures', | ||
ARRAY( | ||
SELECT name FROM tap_funky WHERE schema = $1 and prokind = 'p' | ||
EXCEPT | ||
SELECT $2[i] | ||
FROM generate_series(1, array_upper($2, 1)) s(i) | ||
), | ||
ARRAY( | ||
SELECT $2[i] | ||
FROM generate_series(1, array_upper($2, 1)) s(i) | ||
EXCEPT | ||
SELECT name FROM tap_funky WHERE schema = $1 and prokind = 'p' | ||
), | ||
$3 | ||
); | ||
$$ LANGUAGE SQL; | ||
|
||
-- procedures_are( schema, procedures[] ) | ||
CREATE OR REPLACE FUNCTION procedures_are ( NAME, NAME[] ) | ||
RETURNS TEXT AS $$ | ||
SELECT procedures_are( $1, $2, 'Schema ' || quote_ident($1) || ' should have the correct procedures' ); | ||
$$ LANGUAGE SQL; | ||
|
||
-- procedures_are( procedures[], description ) | ||
CREATE OR REPLACE FUNCTION procedures_are ( NAME[], TEXT ) | ||
RETURNS TEXT AS $$ | ||
SELECT _are( | ||
'procedures', | ||
ARRAY( | ||
SELECT name FROM tap_funky WHERE is_visible and prokind = 'p' | ||
AND schema NOT IN ('pg_catalog', 'information_schema') | ||
EXCEPT | ||
SELECT $1[i] | ||
FROM generate_series(1, array_upper($1, 1)) s(i) | ||
), | ||
ARRAY( | ||
SELECT $1[i] | ||
FROM generate_series(1, array_upper($1, 1)) s(i) | ||
EXCEPT | ||
SELECT name FROM tap_funky WHERE is_visible and prokind = 'p' | ||
AND schema NOT IN ('pg_catalog', 'information_schema') | ||
), | ||
$2 | ||
); | ||
$$ LANGUAGE SQL; | ||
|
||
-- procedures_are( procedures[] ) | ||
CREATE OR REPLACE FUNCTION procedures_are ( NAME[] ) | ||
RETURNS TEXT AS $$ | ||
SELECT procedures_are( $1, 'Search path ' || pg_catalog.current_setting('search_path') || ' should have the correct procedures' ); | ||
$$ LANGUAGE SQL; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4979,7 +4979,7 @@ RETURNS TEXT AS $$ | |
SELECT _are( | ||
'functions', | ||
ARRAY( | ||
SELECT name FROM tap_funky WHERE schema = $1 | ||
SELECT name FROM tap_funky WHERE schema = $1 and kind != 'p' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do we do about people who have used these functions for procedures? With this change, their tests will start failing. I wonder if maybe we should introduce a warning with a deprecation notice and instructions for them to update their tests when |
||
EXCEPT | ||
SELECT $2[i] | ||
FROM generate_series(1, array_upper($2, 1)) s(i) | ||
|
@@ -4988,7 +4988,7 @@ RETURNS TEXT AS $$ | |
SELECT $2[i] | ||
FROM generate_series(1, array_upper($2, 1)) s(i) | ||
EXCEPT | ||
SELECT name FROM tap_funky WHERE schema = $1 | ||
SELECT name FROM tap_funky WHERE schema = $1 and kind != 'p' | ||
), | ||
$3 | ||
); | ||
|
@@ -5006,7 +5006,7 @@ RETURNS TEXT AS $$ | |
SELECT _are( | ||
'functions', | ||
ARRAY( | ||
SELECT name FROM tap_funky WHERE is_visible | ||
SELECT name FROM tap_funky WHERE is_visible and kind != 'p' | ||
AND schema NOT IN ('pg_catalog', 'information_schema') | ||
EXCEPT | ||
SELECT $1[i] | ||
|
@@ -5016,7 +5016,7 @@ RETURNS TEXT AS $$ | |
SELECT $1[i] | ||
FROM generate_series(1, array_upper($1, 1)) s(i) | ||
EXCEPT | ||
SELECT name FROM tap_funky WHERE is_visible | ||
SELECT name FROM tap_funky WHERE is_visible and kind != 'p' | ||
AND schema NOT IN ('pg_catalog', 'information_schema') | ||
), | ||
$2 | ||
|
@@ -5029,6 +5029,62 @@ RETURNS TEXT AS $$ | |
SELECT functions_are( $1, 'Search path ' || pg_catalog.current_setting('search_path') || ' should have the correct functions' ); | ||
$$ LANGUAGE SQL; | ||
|
||
-- procedures_are( schema, procedures[], description ) | ||
CREATE OR REPLACE FUNCTION procedures_are ( NAME, NAME[], TEXT ) | ||
RETURNS TEXT AS $$ | ||
SELECT _are( | ||
'procedures', | ||
ARRAY( | ||
SELECT name FROM tap_funky WHERE schema = $1 and kind = 'p' | ||
EXCEPT | ||
SELECT $2[i] | ||
FROM generate_series(1, array_upper($2, 1)) s(i) | ||
), | ||
ARRAY( | ||
SELECT $2[i] | ||
FROM generate_series(1, array_upper($2, 1)) s(i) | ||
EXCEPT | ||
SELECT name FROM tap_funky WHERE schema = $1 and kind = 'p' | ||
), | ||
$3 | ||
); | ||
$$ LANGUAGE SQL; | ||
|
||
-- procedures_are( schema, procedures[] ) | ||
CREATE OR REPLACE FUNCTION procedures_are ( NAME, NAME[] ) | ||
RETURNS TEXT AS $$ | ||
SELECT procedures_are( $1, $2, 'Schema ' || quote_ident($1) || ' should have the correct procedures' ); | ||
$$ LANGUAGE SQL; | ||
|
||
-- procedures_are( procedures[], description ) | ||
CREATE OR REPLACE FUNCTION procedures_are ( NAME[], TEXT ) | ||
RETURNS TEXT AS $$ | ||
SELECT _are( | ||
'procedures', | ||
ARRAY( | ||
SELECT name FROM tap_funky WHERE is_visible and kind = 'p' | ||
AND schema NOT IN ('pg_catalog', 'information_schema') | ||
EXCEPT | ||
SELECT $1[i] | ||
FROM generate_series(1, array_upper($1, 1)) s(i) | ||
), | ||
ARRAY( | ||
SELECT $1[i] | ||
FROM generate_series(1, array_upper($1, 1)) s(i) | ||
EXCEPT | ||
SELECT name FROM tap_funky WHERE is_visible and kind = 'p' | ||
AND schema NOT IN ('pg_catalog', 'information_schema') | ||
), | ||
$2 | ||
); | ||
$$ LANGUAGE SQL; | ||
|
||
-- procedures_are( procedures[] ) | ||
CREATE OR REPLACE FUNCTION procedures_are ( NAME[] ) | ||
RETURNS TEXT AS $$ | ||
SELECT procedures_are( $1, 'Search path ' || pg_catalog.current_setting('search_path') || ' should have the correct procedures' ); | ||
$$ LANGUAGE SQL; | ||
|
||
-- indexes_are( schema, table, indexes[], description ) | ||
CREATE OR REPLACE FUNCTION indexes_are( NAME, NAME, NAME[], TEXT ) | ||
RETURNS TEXT AS $$ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The migration file is missing the changes to the
functions_are()
functions.