Problem with printf and an sql query

Answered

I have the following line: sqlQuery := fmt.Sprintf("SELECT * FROM `%s` WHERE %s", s.Name, whereClause)

Intellij highlights the first %s as an inspection error, but I can fix it with: //goland:noinspection SqlResolve

However, I cannot tell IntelliJ to get rid of the inspection error on the second %s after the WHERE no matter what I do. I've tried disabling all SQL inspections and I've also tried adding //goland:noinspection All for the line, but the inspection error won't go away.  The inspection help message is “Change SQL Dialect”, which is not useful.

I can fix the problem by changing the string to "SELECT * FROM `%s` WHER"+"E %s" but that is not a very good solution.

How can I get rid of this inspection error?

0
1 comment

Hi Jeffrey,

It's a known issue on our side, please see and follow GO-13537.

As a workaround, you can disable automatic SQL injection, please see: https://youtrack.jetbrains.com/issue/GO-13537/False-positive-inspection-reference-or-ONLY-expected-got#focus=Comments-27-6411851.0-0

0

Please sign in to leave a comment.