SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
[SA 7.2.338 Pro] - Code formatting issue [FIXED]

 
Reply to topic    SoftTree Technologies Forum Index » SQL Assistant View previous topic
View next topic
[SA 7.2.338 Pro] - Code formatting issue [FIXED]
Author Message
gemisigo



Joined: 11 Mar 2010
Posts: 2165

Post [SA 7.2.338 Pro] - Code formatting issue [FIXED] Reply with quote
Formatting SELECT statements falters when multiple function calls are involved in SELECT part of the query. The code below is formatted properly with line #5 commented:
Code:

SELECT
    j.jarat_id          AS id_jarat
   ,j.nyomvon_id        AS id_nyomvon
   ,j.jarat_szam        AS jarat_szam
    --#5   ,CAST(STUFF(STUFF(j.jarat_indulas ,5 ,0 ,':') ,3 ,0 ,':') AS TIME) AS jarat_indulas
   ,j.jarat_tureshatar  AS jarat_tureshatar
   ,j.jarat_helyi_is    AS jarat_helyi_is
   ,j.jarat_korjarat_e  AS jarat_korjarat_e
   ,CAST(j.kozlekedesi_jel_aoeuaoeu_aoeuaoeu AS NVARCHAR(128)) AS kozlekedesi_jel
   ,j.menetido          AS id_menetido
   ,j.datum_tol         AS datum_tol
   ,j.datum_ig          AS datum_ig
   ,j.volan_id          AS id_volan
   ,j.vonal_id          AS id_vonal
FROM
    [DATA].dbo.jarat    AS j
INNER JOIN
    [DATA].dbo.Forda    AS f
    ON  f.jarat_id = j.jarat_id
WHERE   1 = 1
    AND j.datum_tol <= GETDATE()
    AND (GETDATE() < j.datum_ig + 1 OR j.datum_ig IS NULL)
    AND f.datum_tol <= GETDATE()
    AND (GETDATE() < f.datum_ig + 1 OR f.datum_ig IS NULL)
    AND j.uzletag = ''


but the alias alignment is removed beyond that line when it is not:
Code:

SELECT
    j.jarat_id    AS id_jarat
   ,j.nyomvon_id  AS id_nyomvon
   ,j.jarat_szam  AS jarat_szam
   ,CAST(STUFF(STUFF(j.jarat_indulas ,5 ,0 ,':') ,3 ,0 ,':') AS TIME) AS jarat_indulas
   ,j.jarat_tureshatar AS jarat_tureshatar
   ,j.jarat_helyi_is AS jarat_helyi_is
   ,j.jarat_korjarat_e AS jarat_korjarat_e
   ,CAST(j.kozlekedesi_jel_aoeuaoeu_aoeuaoeu AS NVARCHAR(128)) AS kozlekedesi_jel
   ,j.menetido AS id_menetido
   ,j.datum_tol AS datum_tol
   ,j.datum_ig AS datum_ig
   ,j.volan_id AS id_volan
   ,j.vonal_id AS id_vonal
FROM
    [DATA].dbo.jarat AS j
INNER JOIN
    [DATA].dbo.Forda AS f
    ON  f.jarat_id = j.jarat_id
WHERE   1 = 1
    AND j.datum_tol <= GETDATE()
    AND (GETDATE() < j.datum_ig + 1 OR j.datum_ig IS NULL)
    AND f.datum_tol <= GETDATE()
    AND (GETDATE() < f.datum_ig + 1 OR f.datum_ig IS NULL)
    AND j.uzletag = ''



Last edited by gemisigo on Mon Oct 26, 2015 9:17 am; edited 1 time in total
Fri Sep 11, 2015 5:03 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7948

Post Reply with quote
Here is what I get after formatting with all default options, I don't see anything lost here

Code:
/************************************************************
 * Code formatted by SoftTree SQL Assistant © v7.3.396
 * Time: 9/11/2015 9:21:22 AM
 ************************************************************/

SELECT j.jarat_id    AS id_jarat
      ,j.nyomvon_id  AS id_nyomvon
      ,j.jarat_szam  AS jarat_szam
      ,CAST(
           STUFF(STUFF(j.jarat_indulas ,5 ,0 ,':') ,3 ,0 ,':') AS TIME
       ) AS jarat_indulas
      ,j.jarat_tureshatar AS jarat_tureshatar
      ,j.jarat_helyi_is AS jarat_helyi_is
      ,j.jarat_korjarat_e AS jarat_korjarat_e
      ,CAST(j.kozlekedesi_jel_aoeuaoeu_aoeuaoeu AS NVARCHAR(128)) AS
       kozlekedesi_jel
      ,j.menetido AS id_menetido
      ,j.datum_tol AS datum_tol
      ,j.datum_ig AS datum_ig
      ,j.volan_id AS id_volan
      ,j.vonal_id AS id_vonal
FROM   [DATA].dbo.jarat AS j
       INNER JOIN [DATA].dbo.Forda AS f
            ON  f.jarat_id = j.jarat_id
WHERE  1 = 1
       AND j.datum_tol<= GETDATE()
       AND (GETDATE()<j.datum_ig+1 OR j.datum_ig IS NULL)
       AND f.datum_tol<= GETDATE()
       AND (GETDATE()<f.datum_ig+1 OR f.datum_ig IS NULL)
       AND j.uzletag = ''



note that wrapping moves some aliases to the next line, to avoid this, set the text wrapping option in formatting section to 200 chars or something else, the default is just 80 and in my humble opinion is 80 is not enough in many cases.
Fri Sep 11, 2015 9:11 am View user's profile Send private message
gemisigo



Joined: 11 Mar 2010
Posts: 2165

Post Reply with quote
I have Line Length for Code Wrapping set to 220 so I don't think that would be the cause. Besides the result you get is ruined as well. Notice how the first three lines have their aliases aligned (though significantly closer to the beginning of the line than in first case with the renegade line commented) in contrast to the following lines that have their aliases not aligned at all.
Fri Sep 11, 2015 3:53 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7948

Post Reply with quote
Quote:
Besides the result you get is ruined as well.


I suspect it's the result of (CAST ... AS ... ) that throws off alias alignment in this case. I have opened a bug ticket #SA27087 for that issue.
Sat Sep 12, 2015 1:39 am View user's profile Send private message
gemisigo



Joined: 11 Mar 2010
Posts: 2165

Post Reply with quote
Probably, but might not be the cause entirely on its own, as there's another line (#9) containing CAST ... AS and that one does not lead to misalignmend.
Sat Sep 12, 2015 4:58 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7948

Post Reply with quote
A fix for this issue is going to be available in version 7.3
Sat Sep 26, 2015 12:56 pm View user's profile Send private message
gemisigo



Joined: 11 Mar 2010
Posts: 2165

Post Reply with quote
That's good news, thank you very much.
Sat Sep 26, 2015 2:00 pm 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.