Skip to content
Advertisement

IntelliJ IDEA does not recognise specific database schema in Javascript/Typescript files

At some point I was amazed when I managed to set the support of specific schema in my nodejs modules. Unfortunately, later IntelliJ IDEA decided to crash and I needed to remove my .idea folder, thus I lost all of my configurations. So, the problem is that when I write SQL queries it does not find tables or functions which exist in my database. I have it connected in the DB view and can run queries, but I want autocompletion also for SQL queries in Javascript/Typescript files.

So, the question: how to tell to Intellij IDEA that it understands SQL queries for specific database schema in Javascript/Typescript files?

My tries:

  1. I have found that there is search_path environment variable which should do it:

The search_path environment variable in PostgreSQL specifies the order in which schemas are searched. For example, you set the value of search_path to z,a,public, PostgreSQL will look for a value in the z schema. If nothing was not found in the z schema, PostgreSQL looks for the value in the a schema.

PostgreSQL is my case, thus I have tried to add the names of the schemas to search_path (that I have added to as a new property in Advanced tab for my database (maybe it is wrong place?)), but it didn’t help.

  1. I have verified that Settings -> Language Injections contain SQL in Javascript.
  2. I have tried to Attach Session which was offered as a hint to the problem, but it didn’t help.

So, where it could be set?

Advertisement

Answer

As Andrey mentioned in the comment, to resolve this, SQL Resolution Scopes must be configured. This configuration can be found from Settings => Languages & Frameworks => SQL Resolution Scopes.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement