PHPStorm 2016.3: sql generic dialect needs database prefix to autocomplete tables and colum names

In Phpstorm 2016.1 i had the 'generic' SQL dialect for all of my project's files and i was able to auto-complete mysql table names and fields in PHP snippets by referencing directly the table. Example:

$query = "SELECT * FROM users WHERE id = 1";

this was working autocompleting the table 'users' and the column 'id'

In 2016.3 i've noticed i have to specify the database name to get the table and columns autocompletion:

$query = "SELECT * FROM mydatabase.users WHERE id = 1";

I've found that changing the SQL dialect from 'generic' to 'mysql' solves the issue: there is no more need to specify the database prefix for the table, but since 'mysql' dialect produces many syntax errors on many dynamic queries i'have, i can't use this solution.

My question is: can i use the 'generic' dialect and get the auto-complete on tables and fields without specifying the <database> name, in the same way it was working in 2016.1 ?

as a note: i already use a 'default' db in the data source URL:

jdbc:mysql://localhost:3306/mydatabase

Thanks

 

 

0
5 comments
Avatar
Permanently deleted user

Hello,

Are you working with MySQL server? What kind of dynamic queries do you use there?

0

Hello Vladimir,

Yes, i'm working with MySQL server. Most of my queries giving errors with 'mysql' dialect are on this format:

$db->prepare("UPDATE mytable SET " . $ph->getParameters() . " WHERE id= :id " );

This morning i've probably managed to get a solution, changing the query this way:

$db->prepare("UPDATE mytable SET {$ph->getParameters()}  WHERE id= :id " );

and now it doesn't generate error anymore, so i can try to use 'mysql' dialect on my project. 

Anyway, i'm wondering if the issue i'm experiencing with the 'generic' dialect is normal or not

Thanks

0

Please make sure your data source has the Database field filled.
Then, open/create an SQL file with the generic dialect set, press Ctrl+Shift+F10 and select a proper data source for it.
I expect table names to appear without the database prefix.

0

Hello Eugene,

my datasource has the database field filled. Your solution works for .sql files, but not for .php files with SQL strings in it, like the example i've post above

0

Francis, looks like I'm getting the same results: in PhpStorm 10 this is working as you've described.

You can submit a report at http://youtrack.jetbrains.com/issues/WI#newissue=yes for a proper investigation.

0

Please sign in to leave a comment.