SQL embed in JavaScript doesn't see all schemas
Answered
Lets assume i have schemas public and billing +
view reads in schema billing +
code:
// language=PostgreSQL
sequelize.query(`select reads.deleted from reads`) // in JS file
IDEA will show column deleted as unknown, however if i run this query in sql file it will see the column
Additionally, if i write
select reads.deleted from billing.reads
it will also see this column
I want do this without explicitly specifying the schema name
Please sign in to leave a comment.
1. Configure the schema in SQL Resolutions Scopes to be default schema for this file (or folder).
2. make sure this schema is properly introspected and the tables and columns are displaying in database tool widow for this data source. See steps 2 and 4 in Cannot find a database object in the database tree view article.
Hi. Thanks for the answer. Resolution Scopes helped. However, i have another problem with names. Please look at the screenshot. "meters" is a table, "meter$" is a view. There are some examples where IDEA cant recognize the name (but it should because this code works). UPDATE: The problem is with "$" at the end. IDEA's message is "Unable to resolve column meter$".
Do you see this very view in the Database tool window for this schema?
Does it help to quote the identifier?
Hi. Yeah, i see it in Database tool window. Quoting the identifier doesn't help, however, as you can see from the screenshot, alias with the same name helped (line #4). Please note that the problem above doesn't depend on schema but on whether it is a view or a table (in previous message I wrote that the problem is with "$" but i was wrong). So, to summarise a problem: if we don't directly use "dot" operator to access view columns IDEA thinks that a view itself is a column and shows a warning. This is probably a bug.
Thanks for details. Please follow the https://youtrack.jetbrains.com/issue/DBE-9791 Could yo please also specify the IDE version you are using.
Version 2019.2.4. Can you, please, also look at the other 2 posts that i created recently. They are both about IDEA inability to resolve columns but in other circumstances.
1) IDEA can't recognize a type of Array property access
2) IDEA can't recognize Function return type
I decided to create separate posts for that. Idk what is better.