PHPStorm: How do I create an inspection to search for a specific string in SQL? Follow
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.
Please sign in to leave a comment.
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
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"?
This is available only in EAP v.202, for PS too.
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?
Yes, it's planned for the next version
@...
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?
I should not that it DOES work correctly in DataGrip whereas it did not before.
In PS 2021.3 looks good:
@...
Still not working for me in 2021.3:

Steps to reproduce:
Edit > Find > Search Structurally
Choose File Type SQL
Enter `$db$`
See Red Underline under $db$
Not sure what else to do. This does work correctly in DataGrip for me.
Rex Schrader
That must be a project-specific issue. If I open the same project in PS & DB - I would get the same syntax error reported:
vs
I would suggest submitting this to our tracker at https://youtrack.jetbrains.com/newIssue to investigate in details.
Dmitry Tronin - I used to experience the issue in DataGrip, but it was indeed fixed/implemented back in DG 2021.2 (or so). It seemed that this fix was due to be pushed out to PHPStorm, but it has not.
I created a new, blank project in PHPStorm and the issue is still present. I'll open an issue.
Interesting:

This WAS working in DataGrip, but I just opened my inspections and it is now failing in the same way:
This is DataGrip 2021.3.1
Could you please check if this is reproducible in a new project? If it is - could you please share files to reproduce this?
As I mentioned in my message, I created a new, blank project (no files at all) in PHPStorm and was able to reproduce this problem.
Steps to reproduce:
This is still broken in PhpStorm 2022.1.1, although the error presents slightly different. It now says
On a quick test, I was not able to reproduce it on my setup (PhpStorm 2022.1.1):
I wonder why your installation is so specific though.
A generic question: do you have any custom plugins installed?