Is there a way or a plugin to configure SQL Dialec

2019-08-23 06:12发布

问题:

In PhpStorm, I can change global, project or directories settings with existing SQL Dialects, but is there a way to configure SQL Dialects as Symfony/DQL in PhpStorm or a way to detect that App:Panel is a valid entity, not a table? (App:Panel table name is te_panel)

I read this answer which explains that we have to add a Java plugin, because it's currently not possible to add a new SQL Dialect on PhpStorm.

As example, this is an error that PhpStorm is throwing:

The : between App and Panel is not understood. It cannot understand the table name provided (because I provide the name of the Symfony entity).

回答1:

DQL is not supported.

https://youtrack.jetbrains.com/issue/WI-9948 -- watch this ticket (star/vote/comment) to get notified on any progress.


You may try and treat App:Panel as placeholder (similar to how it was described in that linked question). But I have no ideas if it will help (have not really worked with Symfony/DQL so cannot test it myself).

What I may suggest though -- threat the whole query as plain text. Yes, no syntax highlighting and stuff but will not show errors either.

How? One way by placing special comment just before the string, e.g.

->query(/** @lang text */'SELECT ...');

Or by disabling Language Injection rule for SQL altogether.

Alternatively try what has been suggested in this comment -- custom SQL detection syntax(?): https://gist.github.com/willemnviljoen/d20ad8ad0cc365a7e80744328246610f