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

has_pk(:schema, :table) Not defined #287

Closed
aklaver opened this issue Mar 22, 2022 · 5 comments · Fixed by #320
Closed

has_pk(:schema, :table) Not defined #287

aklaver opened this issue Mar 22, 2022 · 5 comments · Fixed by #320

Comments

@aklaver
Copy link

aklaver commented Mar 22, 2022

Postgres 14.2
pgTAP 1.2.0

--Schema and no description
SELECT has_pk('utility', 'eqpt_model_info');
not ok 3 - eqpt_model_info
# Failed test 3: "eqpt_model_info"

--No schema and no description
SELECT has_pk('eqpt_model_info');
ok 3 - Table eqpt_model_info should have a primary key

--Schema and explicit description
SELECT has_pk('utility', 'eqpt_model_info', 'test desc');
ok 3 - test desc

This seems to run counter to the docs:

If the test description is omitted, it will be set to “Table :table should have a primary key”.

@aklaver
Copy link
Author

aklaver commented Mar 22, 2022

All right some time in pgtap.sql.in showed me what is going on. Due to function overloading the only form that automatically sets the description is has_pk( :table ). I was misunderstanding and thought :description was optional in all cases. I now know that the function signatures need to be fully followed for the different forms.

@aklaver aklaver closed this as completed Mar 22, 2022
@theory
Copy link
Owner

theory commented Mar 23, 2022

Oh well perhaps we're missing has_pk(:schema, :table). If we had it you could make sure it's called instead of has_pk(:schema, :desc) by specifying the type:

SELECT has_pk('utility', 'eqpt_model_info'::name);

@theory theory reopened this Mar 23, 2022
@theory theory changed the title has_pk and description has_pk(:schema, :table) Not defined Mar 23, 2022
@aklaver
Copy link
Author

aklaver commented Mar 23, 2022

Yeah, I could see that being helpful. Would that fill in the missing :desc like SELECT has_pk('eqpt_model_info');?

@theory
Copy link
Owner

theory commented Mar 26, 2022

Would that fill in the missing :desc like SELECT has_pk('eqpt_model_info');?

Yes, exactly.

@aklaver
Copy link
Author

aklaver commented Sep 24, 2023

Thanks.

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

Successfully merging a pull request may close this issue.

2 participants