PHPStorm: How do I create an inspection to search for a specific string in SQL?

Answered

I have a series of migration files in SQL that I would like to ensure do not get a development database name.  

How can I set up an inspection for "some_database_name" in all SQL files?

I built an inspection with a Search Template, but I couldn't just put in `$_1$` alone.  I put it with a suffix of `.` and it alerts on every single `.` in my SQL.

Ideally, I'd like to be able to have it highlight/red underline the entire database name anytime it is found in an SQL file.

7 comments
Comment actions Permalink

Edit -> Find -> Search Structurally, add something like this:

Then press on Wrench icon and choose 'Save template as Inspection.

But unfortunately this does not work at the moment, we expected to fix it in v.2021.1.1

0
Comment actions Permalink

This appears to be specific to DataGrip (which is helpful for me too), but doesn't work in PHPStorm? 

At least, I get an error "The specified pattern is malformed"

Or is that what you mean by "does not work in the moment"?

0
Comment actions Permalink

This is available only in EAP v.202, for PS too.

1
Comment actions Permalink

I just installed PHPStorm 2021.1.1 and it this inspection doesn't seem to work yet. It also doesn't work in the latest released DataGrip 2021.1.  Has this fixed been pushed to a future version?

0
Comment actions Permalink

Yes, it's planned for the next version

0
Comment actions Permalink

Yuriy Vinogradov
I have PHPStorm v2021.2.2 and it does not yet have a fix for this.

Can you please advise which version I can expect to see it in?

0
Comment actions Permalink

I should not that it DOES work correctly in DataGrip whereas it did not before.

0

Please sign in to leave a comment.