Reformat SOQL in Apex - 1 Field per line

Issue #2444 resolved
Grant Millgate created an issue

Some way to reformat this: acr = [SELECT Id, Roles, Roles_Portal_Viewable__c FROM AccountContactRelation WHERE Id = :acr.Id LIMIT 1];

to:

acr = [
SELECT
Id,
Roles,
Roles_Portal_Viewable__c
FROM AccountContactRelation
WHERE Id = :acr.Id
LIMIT 1
];

Comments (6)

  1. Scott Wells repo owner
    • changed status to open

    Thanks for logging this. I’ve been thinking about something similar myself, at a minimum a code intention to put each selected field/function on its own line just like the ones that exist for formal parameters/arguments.

  2. Scott Wells repo owner

    Okay, I’ve committed new code intentions to easily split even more delimited lists one per-line or consolidate them onto a single line similar to what was already present for method formal parameters and invocation arguments. In particular, I’ve added support for the following:

    • SOQL SELECT clause items
    • SOQL GROUP BY clause fields
    • SOQL ORDER BY clause fields
    • SOQL WHERE clause logical expressions
    • SOQL WHERE clause parenthesized value sets
    • Apex composite (logical and arithmetic) expressions
    • Apex array/list and map initializer entries

    Here’s a short example of the SOQL-specific ones:

    These should all be in this week’s build, likely for release on Thursday.

  3. Scott Wells repo owner

    Yes, absolutely. It’s all the same editor, just used in different contexts. All of the enhancements described above will work in the standard Apex editor including for embedded SOQL queries.

  4. Log in to comment