kristijanhusak / vim-dadbod-ui

Simple UI for https://github.com/tpope/vim-dadbod
MIT License
1.53k stars 92 forks source link

fix(postgres): Primary Keys table helper #264

Open wburklund opened 4 months ago

wburklund commented 4 months ago

The current Primary Keys table helper for Postgres doesn't list primary keys as expected because it joins against information_schema.referential_constraints, which only has foreign keys.

To reproduce:

  1. Spin up the current stable version of PostgreSQL (16.3).
  2. Create a table with a primary key:
    CREATE TABLE pk_test (
    id INT,
    name TEXT,
    PRIMARY KEY (id)
    );
  3. Run the existing Primary Keys table helper and see that the primary key is not listed.

This PR fixes the Primary Keys table helper by simply querying against information_schema.table_constraints. It also renames basic_constraint_query to indicate it should only be used for foreign key queries.