javaintellij-ideaintellij-idea-2018

Upgraded to Intellij 2018.1 and now I'm getting an error for public static final String constants that are referenced in SQL code


All my classes that have public static final String NAME = "value" that are used in SQL queries are now getting a compiler error " or DELIMITER expected, got 'lastname'".

enter image description here

You can also find the code below in case it helps replicate it.

public class PeopleSQL
{
    public static final String ID_COL = "id";
    public static final String FIRSTNAME_COL = "firstname";
    public static final String LASTNAME_COL = "lastname";

    public static void getListOfPeople(Connection connection) throws RanaSQLException
    {
        PreparedStatement statement = null;
        ResultSet result = null;

        try
        {
            statement = connection.prepareStatement("SELECT " + ID_COL + ", " + LASTNAME_COL + " FROM people");
            result = statement.executeQuery();

        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            try
            {
                result.close();
                statement.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }
}


class People
{

}

And yes I've filed a bug report.


Solution

  • This is a bug with the new Intellij 2018.1 Edition and a bug report has been issued: https://youtrack.jetbrains.com/issue/IDEA-188988

    Below is a screenshot of the temporary workaround. You basically need to disable a setting.

    enter image description here