Code inspection not recognising table names

Hi all,

 

I have a project open in PHPStorm and on the right it is showing my connection to the database and relevant schema.

I can expand the tables and see the fields etc in the database "window".

My problem is in my actual code, within the SQL statements it is not recognising the table names.

Any idea how to fix this please?

Thanks in advance!

0
6 comments

Well this is a useful support tool..... not :/

0

Hi there,

Try check stuff at "Settings (Preferences on macOS) | Languages & Frameworks | SQL Resolution Scopes"

https://www.jetbrains.com/help/phpstorm/2019.2/settings-languages-sql-resolution-scopes.html

Could also be related to how your DB Connection is defined (how many schemas are available for that login/what schema is selected in DB connection).

In my project where no ORM is used (so it has SQL queries like yours), it works just fine right out of the box, so it's hard to suggest something more specific for me right now.

1

Thank you Andriy :)

I was using a username in the DB Connection that had access to 15 databases.

I changed to using a username that only had access to the database in question and now it works fine.

I'm not 100% sure if this is intended functionality or a bug - but you have solved it so thank you very much!

0

>I'm not 100% sure if this is intended functionality or a bug

I think it should be a matter of settings: what schemas were selected in DB Connection properties and use that SQL Resolution Scopes (select desired DB for the whole project) -- should have worked.

I'm always trying to use minimal access policy (or whatever the proper name is for that; so user can access single DB only) and it works just fine for me during development -- never faced such issue before.

0

Hi Andriy Bazanov —

I was having the same problem (in GoLand) and your solution was not working for me and it was absolutely driving me bonkers. 

I finally realized GoLand was trying to inspect for Sqlite when my project was using MySQL. Sure enough, after following that hunch I found  Settings/Preferences > Languages & Frameworks > SQL Dialects and there I found my "Global SQL Dialect" setting was for "SQLite" and I did not have a "Project SQL Dialect." It only took changing the setting for Project SQL Dialect to "MySQL" to resolve my issue. 

Posting here for the next frustrated person who finds the page while googling because they were having the same problem I was having.

2

Please sign in to leave a comment.