Page 1 of 1

Format SQL Code has problem with condition wrapping

Posted: Tue 10 Nov 2015 18:19
by astr0wiz
Multiple conditions in WHERE clauses and ON clauses in JOINs do not honor the settings using the online tool. Here is the code I used, unformatted:

Code: Select all

declare
    @Cycle int = 42;
BEGIN
    SELECT FI.this,       FI.that
, RI.SomethingElse / FIT.ADivisor,
        fi.MoreData
    from  FInvoice FI left join RInfo RI on RI.id = FI.fi_id
                            and RI.ACode = FI.ACode
    join FITypes FIT on FIT.ACode = FI.ACode and FIT.TypeCode = FI.TypeCode
where (FI.CountryISOCode in ('ABC'))
or (FIT.VAT_Split = 1)
 and Cycle = @Cycle
 ;
END
In the SELECT / WHERE / Wrap Condition options, I have checked After logical operator / Any operator. The Before logical operator section is unchecked.
The following is what results after pressing FORMAT. Please note the WHERE condition.

Code: Select all

declare
    @Cycle int = 42;
begin
    select
        FI.this,
        FI.that,
        RI.SomethingElse / FIT.ADivisor,
        fi.MoreData
    from
        FInvoice FI
        left join RInfo RI
            on RI.id = FI.fi_id
                and RI.ACode = FI.ACode
        join FITypes FIT
            on FIT.ACode = FI.ACode
                and FIT.TypeCode = FI.TypeCode
    where
        (FI.CountryISOCode in ('ABC'))
        or (FIT.VAT_Split = 1)
        and Cycle = @Cycle
    ;
end
What I *want* to see is this:

Code: Select all

    where
        (FI.CountryISOCode in ('ABC')) or
        (FIT.VAT_Split = 1) and
        Cycle = @Cycle
I have tried several different WHERE clause examples from our code base which use multiple conditions of varying complexity, but they all act like Before logical operator / Any operator is checked, instead of After logical operator / Any operator.

I need this kind of formatting also with the ON clauses in my JOIN queries as some of our scripts are very complex and difficult to read.

So, have I made the correct settings to do this, or is there truly an issue with the formatter?

Re: Format SQL Code has problem with condition wrapping

Posted: Wed 11 Nov 2015 09:30
by alexa
We will fix this issue shortly.

Re: Format SQL Code has problem with condition wrapping

Posted: Wed 11 Nov 2015 16:10
by astr0wiz
alexa wrote:We will fix this issue shortly.
Thanks! :)

Now, the 2nd part of my question, which I failed to ask already, was: is this a problem with the db Forge SQL Complete package as well? I ask because I would like to purchase the product but will not if the formatting is problematic.

Re: Format SQL Code has problem with condition wrapping

Posted: Wed 11 Nov 2015 17:21
by alexa
The add-in dbForge SQL Complete has no such a problem. You can download a fully featured 30-day Trial version and try it https://www.devart.com/dbforge/sql/sqlc ... nload.html

Re: Format SQL Code has problem with condition wrapping

Posted: Wed 11 Nov 2015 18:23
by astr0wiz
alexa wrote:The add-in dbForge SQL Complete has no such a problem.
Thank you. :)