Force detection of SQL query

When one has a query that starts with a complex table expression (WITH), it looks like the IDE won't auto-detect the string as a SQL query.

Is there a way to make it do the proper detection (annotation in code, or some IDE setting change)?

sample Python code with the query would be something like this

sql = """with cte as (select foo from bar)
select * from cte"""
3 comments
Comment actions Permalink

Although the same query you attached is automatically detected for me as sql fragment, you can use Alt+Enter Intention action to inject the language in a string literal:

Please check also https://www.jetbrains.com/pycharm/help/using-language-injections.html .

0
Comment actions Permalink

I'm on PHPStorm 2017.2.4 with the IntelliLang plugin enabled

Going to Settings->Editor-Language Injections lets you modify how the default matching works. (first image)

It appears to use regex. I've added a check for when i DECLARE sql variables in a string literal before SELECTing. (second image)



0

Please sign in to leave a comment.