SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
Applying formatting rules

 
Reply to topic    SoftTree Technologies Forum Index » SQL Assistant View previous topic
View next topic
Applying formatting rules
Author Message
gemisigo



Joined: 11 Mar 2010
Posts: 2102

Post Applying formatting rules Reply with quote
How are the formatting rules applied to the code in the editor? Do they have any order or priority? What about overlapping rules?
Thu Sep 14, 2017 10:20 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7840

Post Reply with quote
The order is important, that's why there are controls in the Options dialog allowing to move rules up and down. when you refer to overlapping rules, I guess you mean rules to contain formatting pattern which is also referenced somehow in another rules. Rules are matched in the order they are specified, the processing doesn't stop after the first found rule, it continues after the rule is applied, that's why overlapping isn't really an issue
Fri Sep 15, 2017 9:34 am View user's profile Send private message
gemisigo



Joined: 11 Mar 2010
Posts: 2102

Post Reply with quote
Are you saying it is possible to have a rule for SELECT that would be overridden by another rule lower on the list in case the code has eg. an additional INTO keyword that the rule higher on the list would not touch when formatting the statement?
Fri Sep 15, 2017 9:47 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7840

Post Reply with quote
That might produce unexpected side effect, I would say it's a grey area, but you may have SELECT ... INTO... FROM... WHERE rule, and a separate ...FROM..., and ...WHERE ... rules.
Fri Sep 15, 2017 10:01 am View user's profile Send private message
gemisigo



Joined: 11 Mar 2010
Posts: 2102

Post Reply with quote
I've read in help (and also recall you stating somewhere) that:
Quote:

Keywords included in the pattern that do not appear in the statement are ignored during code processing and do not affect the results.


But that doesn't always seem to be true. I have the following rule for SELECT:
Code:

SELECT
    ... AS ...
   ,... = ...
INTO ...
FROM
    ... AS ...
   ,...
JOIN
    ...
    ON  ... = ...
        AND ...
        OR  ...
WHERE   ... = ...
    AND ...
    OR  ...
GROUP BY
    ...
   ,...
HAVING
    ...
   ,...
ORDER BY
    ...
   ,...
;


That formats a piece of code so that the result is like below:
Code:

SELECT
    opm.CI
   ,opm.KI               AS KI_most
   ,ope.KI               AS KI_elotte
INTO ##keses_sietes_elteresek
FROM
    #online_plusz_most AS opm
INNER JOIN
    ##online_plusz_elozo AS ope
    ON  ope.CI = opm.CI
        AND ope.jarat_id = opm.jarat_id
        AND (ope.KI / 60 != opm.KI / 60 AND ope.KI IS NOT NULL AND opm.KI IS NOT NULL)
;

which is more or less what I want (notice that the alias for table #online_plusz_most was not properly aligned).

However, removing the line with the keyword INTO will result in ruining the rest of the code:
Code:

SELECT
    opm.CI
   ,opm.KI                AS KI_most
   ,ope.KI                AS KI_elotte
    FROM
    #online_plusz_most    AS opm
    INNER JOIN
    ##online_plusz_elozo  AS ope
    ON ope.CI = opm.CI
    AND ope.jarat_id = opm.jarat_id
    AND (ope.KI / 60 != opm.KI / 60 AND ope.KI IS NOT NULL AND opm.KI IS NOT NULL)


Removing the INTO part from the rule will restore order, with the formatting result of:
Code:

SELECT
    opm.CI
   ,opm.KI                AS KI_most
   ,ope.KI                AS KI_elotte
FROM
    #online_plusz_most    AS opm
INNER JOIN
    ##online_plusz_elozo  AS ope
    ON  ope.CI = opm.CI
        AND ope.jarat_id = opm.jarat_id
        AND (ope.KI / 60 != opm.KI / 60 AND ope.KI IS NOT NULL AND opm.KI IS NOT NULL)
;


But that in turn makes malformatting INTO in the original code, in case it is present:
Code:

SELECT
    opm.CI
   ,opm.KI  AS KI_most
   ,ope.KI  AS KI_elotte
    INTO ##keses_sietes_elteresek
FROM
    #online_plusz_most AS opm
INNER JOIN
    ##online_plusz_elozo AS ope
    ON  ope.CI = opm.CI
        AND ope.jarat_id = opm.jarat_id
        AND (ope.KI / 60 != opm.KI / 60 AND ope.KI IS NOT NULL AND opm.KI IS NOT NULL)
;


By the way, I tried to reorder the rules. The rule sets can be reordered using the controls there

, yet the modifications done to them do not persist (closing and reopening the SA - Options window will restore the original order, see post here).

The individual rules themselves lack that control. Though there are items for Move Up/Down in their context menu

those do not work (or at least not as I'd expect). Move down only moves selection down one item, not the item itself. Move up does not even do that. It seems the rules are always ordered alphabetically. I've tried moving by renaming them so that they would swap their order but I ended up not fixing anything doing that.
Fri Sep 22, 2017 5:43 am View user's profile Send private message
Display posts from previous:    
Reply to topic    SoftTree Technologies Forum Index » SQL Assistant All times are GMT - 4 Hours
Page 1 of 1

 
Jump to: 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


 

 

Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Flowers Online.