continuedev / continue

⏩ Continue is the leading open-source AI code assistant. You can connect any models and any context to build custom autocomplete and chat experiences inside VS Code and JetBrains
https://docs.continue.dev/
Apache License 2.0
19.25k stars 1.66k forks source link

Postrges context provider can't handle multiple shemas #2823

Open Seniorsimo opened 1 week ago

Seniorsimo commented 1 week ago

Before submitting your bug report

Relevant environment info

- OS: Windows 11
- Continue version: 0.8.55
- IDE version: VS Code 1.95
- Model:
- config.json:

...
{
      "name": "postgres",
      "params": {
        "host": "<db_host>",
        "port": 5432,
        "user": "<db_root>",
        "password": "<db_password>",
        "database": "<db-name>",
        "schema": "",
        "sampleRows": 3
      }
    },
...

Description

The docs says that leaving the schema field unset, or empty this should permit the access to all schemas inside a database, but this is not working: if I put schema = null the access will defaulting back to the "public" schema, and when I put shema = "" no shema will be selected and visible. If I need to acces 2 schema on the same istance, I have to create 2 entries, one for each schema, like:

{
      "name": "postgres",
      "params": {
        "host": "<db_host>",
        "port": 5432,
        "user": "<db_root>",
        "password": "<db_password>",
        "database": "<db-name>",
        "schema": "<schema_1>",
        "sampleRows": 3
      }
    },
{
      "name": "postgres",
      "params": {
        "host": "<db_host>",
        "port": 5432,
        "user": "<db_root>",
        "password": "<db_password>",
        "database": "<db-name>",
        "schema": "<schema_2>",
        "sampleRows": 3
      }
    },

In this way it works, but is a little difficult, because the GUI doesn't show any sort of identifier for the database. There are 2 connections, but to know wich one it will be used you have to actually select, and if it's the wrong one, repeat until you get che desired one. image

Suggestion: fix in a way that an empty string "" will grant access to all table in all schema or add some sort of identifier on the postgres context provider to make it usable (maybe just like the "database" provider, make a list of connection.

Extra: I switched to postgres context provider because the "database" one, for postres, will allow only to inspect the "public" schema. This will bring me to think why there is actually a specific context provider for postgres? Shouldn't be more easy to handle just by adding the "shema" selection on the database one? This will resolve not only the multischema problem, but also the multi connection problem: if i need to access 2 posgress istances, i have to setup 2 connection and those are displayed the same way as in the picture

To reproduce

  1. open the config.json file
  2. add a postgrs connection to a database with multiple shemas
  3. set the "schema" in the configuration to an empty string ""
  4. try to call the context provider from the chat

At this point no schema is visible

Log output

No response

DifferentialityDevelopment commented 16 hours ago

Try the database adapter with a postgres connection instead, you can give each connection a name It makes use of the dbinfoz package https://www.npmjs.com/package/dbinfoz/v/0.14.0 https://docs.continue.dev/customize/context-providers#database

Seniorsimo commented 15 hours ago

Yes, i've also tried that, but as i sayd, it seems that it only works with the "public" schema. So I can have multiple connections, but i can't access any schema other that the public one unfortunatly. Is some undocumented way to set the schema on the "database" adapter?

The public schema seems pretty hardcoded in that: image