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

col_is_unique not working on PostgreSQL 8.3 #14

Closed
guedes opened this issue Sep 23, 2011 · 2 comments
Closed

col_is_unique not working on PostgreSQL 8.3 #14

guedes opened this issue Sep 23, 2011 · 2 comments

Comments

@guedes
Copy link

guedes commented Sep 23, 2011

I'm using pgtap-0.25 and I'm getting this behaviour:

des=# BEGIN ;
BEGIN
des=# \d tb_g00
           Tabela "some.tb_g00"
       Coluna        |            Tipo             | Modificadores 
---------------------+-----------------------------+---------------
 cod                 | numeric(10,0)               | not null
 typ                 | integer                     | not null
 nro                 | character varying(12)       | not null
Indices:
    "pk_g00" PRIMARY KEY, btree (cod, typ)
    "ui_g00" UNIQUE, btree (cod, nro)
Restricoes de chave estrangeira:
    "fk_g11_g00" FOREIGN KEY (cod) REFERENCES tb_g11(cod) ON UPDATE CASCADE

des=# SELECT plan(1);
 plan 
------
 1..1
(1 registro)

des=# SELECT pgtap.col_is_unique('tb_g00', ARRAY['cod', 'nro']);
                                                        col_is_unique                                                         
------------------------------------------------------------------------------------------------------------------------------
 not ok 2 - Columns tb_g00(cod, nro) should have a unique constraint
 # Failed test 2: "Columns tb_g00(cod, nro) should have a unique constraint"
 #         have: 
 #         want: {cod,nro}
(1 registro)
@theory
Copy link
Owner

theory commented Sep 23, 2011

Yes, I believe that's because it's a unique index, not a unique constraint. Use this instead:

SELECT pgtap.has_index('tb_g00', 'ui_g00', ARRAY['cod', 'nro']);
SELECT pgtap.index_is_unique('tb_g00', 'ui_g00');

HTH,

David

@theory theory closed this as completed Sep 23, 2011
@guedes
Copy link
Author

guedes commented Sep 23, 2011

Hum, I've misunderstood that, thanks!

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

No branches or pull requests

2 participants