Skip to content
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

Add missing function has_composite() without desc #339

Merged
merged 1 commit into from
Nov 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Changes
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ Revision history for pgTAP
* Fixed the upgrade from v1.2.0 to v1.3.0. Thanks to @runqitian for the pull
request (#338).

* Added `name, name` variants for `has_composite` and `hasnt_composite` Thanks
to Jim Nasby for reporting the issue (#234) Rodolphe Quiédeville for for the
pull request (#339).

1.3.3 2024-04-08T13:44:11Z
--------------------------

Expand Down Expand Up @@ -278,7 +282,7 @@ Revision history for pgTAP
Quiédeville (PR #106).
* Add `has_extension()` and `hasnt_extension()`. Thanks to Rodolphe Quiédeville
(PR #101).

0.96.0 2016-05-16T20:53:57Z
---------------------------
* Added an optional `:exclude_pattern` parameter to `findfuncs()` to prevent
Expand Down
6 changes: 3 additions & 3 deletions compat/install-9.1.patch
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
RETURN ok( FALSE, descr ) || E'\n' || diag(
' died: ' || _error_diag(SQLSTATE, SQLERRM, detail, hint, context, schname, tabname, colname, chkname, typname)
);
@@ -6698,10 +6694,6 @@
@@ -6732,10 +6728,6 @@
-- Something went wrong. Record that fact.
errstate := SQLSTATE;
errmsg := SQLERRM;
Expand All @@ -22,15 +22,15 @@
END;

-- Always raise an exception to rollback any changes.
@@ -7169,7 +7161,6 @@
@@ -7203,7 +7195,6 @@
RETURN ok( true, $3 );
EXCEPTION
WHEN datatype_mismatch THEN
- GET STACKED DIAGNOSTICS err_msg = MESSAGE_TEXT;
RETURN ok( false, $3 ) || E'\n' || diag(
E' Number of columns or their types differ between the queries' ||
CASE WHEN have_rec::TEXT = want_rec::text THEN '' ELSE E':\n' ||
@@ -7323,7 +7314,6 @@
@@ -7357,7 +7348,6 @@
RETURN ok( false, $3 );
EXCEPTION
WHEN datatype_mismatch THEN
Expand Down
2 changes: 1 addition & 1 deletion compat/install-9.2.patch
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
RETURN ok( FALSE, descr ) || E'\n' || diag(
' died: ' || _error_diag(SQLSTATE, SQLERRM, detail, hint, context, schname, tabname, colname, chkname, typname)
);
@@ -6706,12 +6701,7 @@
@@ -6740,12 +6735,7 @@
GET STACKED DIAGNOSTICS
detail = PG_EXCEPTION_DETAIL,
hint = PG_EXCEPTION_HINT,
Expand Down
2 changes: 1 addition & 1 deletion compat/install-9.4.patch
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
-- There should have been no exception.
GET STACKED DIAGNOSTICS
detail = PG_EXCEPTION_DETAIL,
@@ -10250,233 +10250,6 @@
@@ -10284,233 +10284,6 @@
), $2);
$$ LANGUAGE SQL immutable;

Expand Down
2 changes: 1 addition & 1 deletion compat/install-9.6.patch
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--- sql/pgtap.sql
+++ sql/pgtap.sql
@@ -10232,136 +10232,6 @@
@@ -10266,136 +10266,6 @@
);
$$ LANGUAGE sql;

Expand Down
18 changes: 17 additions & 1 deletion sql/pgtap--1.3.3--1.3.4.sql
Original file line number Diff line number Diff line change
@@ -1 +1,17 @@
-- TBD
-- has_composite( schema, type )
CREATE OR REPLACE FUNCTION has_composite ( NAME, NAME )
RETURNS TEXT AS $$
SELECT has_composite(
$1, $2,
'Composite type ' || quote_ident($1) || '.' || quote_ident($2) || ' should exist'
);
$$ LANGUAGE SQL;

-- hasnt_composite( schema, type )
CREATE OR REPLACE FUNCTION hasnt_composite ( NAME, NAME )
RETURNS TEXT AS $$
SELECT hasnt_composite(
$1, $2,
'Composite type ' || quote_ident($1) || '.' || quote_ident($2) || ' should not exist'
);
$$ LANGUAGE SQL;
17 changes: 17 additions & 0 deletions sql/pgtap.sql.in
Original file line number Diff line number Diff line change
Expand Up @@ -1223,6 +1223,14 @@ RETURNS TEXT AS $$
SELECT ok( _rexists( 'c', $1, $2 ), $3 );
$$ LANGUAGE SQL;

-- has_composite( schema, type )
CREATE OR REPLACE FUNCTION has_composite ( NAME, NAME )
RETURNS TEXT AS $$
SELECT has_composite($1, $2,
'Composite type ' || quote_ident($1) || '.' || quote_ident($2) || ' should exist'
);
$$ LANGUAGE SQL;

-- has_composite( type, description )
CREATE OR REPLACE FUNCTION has_composite ( NAME, TEXT )
RETURNS TEXT AS $$
Expand All @@ -1241,6 +1249,15 @@ RETURNS TEXT AS $$
SELECT ok( NOT _rexists( 'c', $1, $2 ), $3 );
$$ LANGUAGE SQL;

-- hasnt_composite( schema, type )
CREATE OR REPLACE FUNCTION hasnt_composite ( NAME, NAME )
RETURNS TEXT AS $$
SELECT hasnt_composite(
$1, $2,
'Composite type ' || quote_ident($1) || '.' || quote_ident($2) || ' should not exist'
);
$$ LANGUAGE SQL;

-- hasnt_composite( type, description )
CREATE OR REPLACE FUNCTION hasnt_composite ( NAME, TEXT )
RETURNS TEXT AS $$
Expand Down
1,643 changes: 826 additions & 817 deletions test/expected/hastap.out

Large diffs are not rendered by default.

42 changes: 34 additions & 8 deletions test/sql/hastap.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
\i test/setup.sql
-- \i sql/pgtap.sql

SELECT plan(1004);
SELECT plan(1013);
--SELECT * FROM no_plan();

-- This will be rolled back. :-)
Expand Down Expand Up @@ -579,6 +579,23 @@ SELECT * FROM check_test(
''
);

SELECT * FROM check_test(
has_composite( 'public'::name, '__SDFSDFD__'::name ),
false,
'has_composite(schema, type)',
'Composite type public."__SDFSDFD__" should exist',
''
);

SELECT * FROM check_test(
has_composite( 'public'::name, 'sometype'::name ),
true,
'has_composite(schema, type)',
'Composite type public.sometype should exist',
''
);


SELECT * FROM check_test(
has_composite( 'public', 'sometype', 'desc' ),
true,
Expand Down Expand Up @@ -638,6 +655,15 @@ SELECT * FROM check_test(
''
);

SELECT * FROM check_test(
hasnt_composite( 'public'::name, '__SDFSDFD__'::name ),
true,
'hasnt_composite(schema, non-existent type',
'Composite type public."__SDFSDFD__" should not exist',
''
);


SELECT * FROM check_test(
hasnt_composite( 'public', 'sometype', 'desc' ),
false,
Expand Down Expand Up @@ -665,7 +691,7 @@ SELECT * FROM check_test(
SELECT * FROM check_test(
has_type( 'public'::name, 'sometype'::name ),
true,
'has_type(scheam, type)',
'has_type(schema, type)',
'Type public.sometype should exist',
''
);
Expand Down Expand Up @@ -2305,7 +2331,7 @@ SELECT * FROM check_test(
domain_type_is( 'public'::name, 'us_postal_code', 'text'),
true,
'domain_type_is(schema, domain, type)',
'Domain public.us_postal_code should extend type text',
'Domain public.us_postal_code should extend type text',
''
);

Expand Down Expand Up @@ -2346,7 +2372,7 @@ SELECT * FROM check_test(
domain_type_is( 'us_postal_code', 'text'),
true,
'domain_type_is(domain, type)',
'Domain us_postal_code should extend type text',
'Domain us_postal_code should extend type text',
''
);

Expand Down Expand Up @@ -2428,7 +2454,7 @@ SELECT * FROM check_test(
domain_type_isnt( 'public'::name, 'us_postal_code', 'int'),
true,
'domain_type_isnt(schema, domain, type)',
'Domain public.us_postal_code should not extend type int',
'Domain public.us_postal_code should not extend type int',
''
);

Expand Down Expand Up @@ -2469,7 +2495,7 @@ SELECT * FROM check_test(
domain_type_isnt( 'us_postal_code', 'int'),
true,
'domain_type_isnt(domain, type)',
'Domain us_postal_code should not extend type int',
'Domain us_postal_code should not extend type int',
''
);

Expand Down Expand Up @@ -2503,7 +2529,7 @@ SELECT * FROM check_test(
CREATE FUNCTION test_fdw() RETURNS SETOF TEXT AS $$
DECLARE
tap record;
BEGIN
BEGIN
IF pg_version_num() >= 90100 THEN
EXECUTE $E$
CREATE FOREIGN DATA WRAPPER dummy;
Expand Down Expand Up @@ -3272,7 +3298,7 @@ BEGIN
) AS b LOOP
RETURN NEXT tap.b;
END LOOP;

FOR tap IN SELECT * FROM check_test(
has_view( 'pg_tables' ),
true,
Expand Down
Loading