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

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

Open
sangaline opened this issue Apr 17, 2022 · 2 comments

Comments

@sangaline
Copy link

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
@abo-abo
Copy link

abo-abo commented Aug 31, 2022

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.

@cizordj
Copy link

cizordj commented Nov 11, 2022

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

aokiji pushed a commit to aokiji/sqls that referenced this issue Mar 20, 2024
tries to add some support for completion when working with other
schemas.

join snippets are not supported yet as foreign key information
gathered for the other schemas is not updated in the cache as it is
done with the column description

this partially solves issue sqls-server#99
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

3 participants