sqls icon indicating copy to clipboard operation
sqls copied to clipboard

Postgres completions don't work for tables outside of the "public" schema

Open sangaline opened this issue 4 years ago • 2 comments

Describe the bug

It seems like sqls has trouble with code completions and hover when dealing with a table outside of the public schema in Postgres. Both actions work fine for me for tables in the public schema, but return no results for tables in other schemas.

To Reproduce

Create a table in the default public schema, and one in another schema:

CREATE TABLE cat (
    age          integer,
    owner_name   varchar(40)
);

CREATE SCHEMA my_schema;
CREATE TABLE my_schema.owner (
    age    integer,
    name   varchar(40)
);

Write a query involving the two tables and experiment with completion on each table through sqls:

SELECT
   cat.age AS cat_age,
   owner.age AS owner_age 
FROM
   cat 
   JOIN
      my_schema.owner AS owner 
    ON cat.owner_name = owner.name;

In particular, try to complete from owner. or my_schema.owner.. Also try to perform a hover action over owner.

Expected behavior

I would expect completion to work on both the cat and owner tables. Instead, it only works on cat. This is true regardless of whether the full my_schema.owner. prefix is used or the owner alias. Similarly, I would expect textDocument/hover to work for both cat and owner, but it only works for cat.

Versions (please complete the following information):

  • OS Version: Linux 5.17.1
  • sqls Version: 0.2.22

sangaline avatar Apr 17 '22 19:04 sangaline

I've hit the same issue. I just started using sqls and was trying to get completions on some pg_catalog.* tables and they didn't work. Luckily the gifs in the README convinced me to keep trying and see that completions actually work fine in the public schema.

abo-abo avatar Aug 31 '22 13:08 abo-abo

I use Postgres on my daily work and I'm having this issue as well.

cizordj avatar Nov 11 '22 11:11 cizordj