Skip to content

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

@sangaline

Description

@sangaline

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions