Skip to content

Switch plan(int) to plan(bigint) #348

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jnasbyupgrade
Copy link

A useful test pattern is to define a matrix of tests in a table or view by building a cartesian join of multiple dimensions. If you do that, you'll want to do something along the lines of

SELECT plan(
0

  • (SELECT count(*) FROM test_view) );

Because count() returns bigint doing this with plan(int) forces you to cast the output of count() to int. Switching plan() to accept a bigint removes the need for that cast.

A useful test pattern is to define a matrix of tests in a table or view
by building a cartesian join of multiple dimensions. If you do that,
you'll want to do something along the lines of

SELECT plan(
  0
  + <some number of static tests>
  + (SELECT count(*) FROM test_view)
);

Because count(*) returns bigint doing this with plan(int) forces you to
cast the output of count(*) to int. Switching plan() to accept a bigint
removes the need for that cast.
@jnasbyupgrade
Copy link
Author

@theory shouldn't this PR have kicked off an automated test run?

@theory
Copy link
Owner

theory commented Apr 18, 2025

It would have if you didn't keep changing your damn GitHub account name, @jnasbyupgrade! Is this who you are now? Currently the collaborators are:

image

@@ -10,6 +10,9 @@ Revision history for pgTAP
to Jim Nasby for reporting the issue (#234) Rodolphe Quiédeville for for the
pull request (#339).
* Added `index_is_partial()`, thanks to Rodolphe Quiédeville (#342).
* Change plan() to accept bigint. While only an insane person would need more
than 2^31 tests, the bigint version makes calling plan with the count(*) of
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it just as easy to use plan(COUNT(*)::int)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants