SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
[11.5.362 Pro] - Formatting VALUES rule

 
Reply to topic    SoftTree Technologies Forum Index » SQL Assistant View previous topic
View next topic
[11.5.362 Pro] - Formatting VALUES rule
Author Message
gemisigo



Joined: 11 Mar 2010
Posts: 2108

Post [11.5.362 Pro] - Formatting VALUES rule Reply with quote
SA seems to have some trouble recognizing what should be considered to be part of the VALUES clause (or at least I have trouble explaining that to SA, that's still open for debate).

Here are the rules:
I separated the INSERT part from the VALUES part because if I joined them into a single rule, having an INSERT INTO ... SELECT statement instead of VALUES produced some weird results. Here is the one for the INSERT part.
Code:

INSERT ...(..., ...)


And VALUES has the following:
Code:

    VALUES (..., ...)
          ,(..., ...);

Notice that the VALUES keyword is already indented so formatting the code below would produce the desired indentation of the VALUES keyword regarding the INSERT keyword
And here is the code to be formatted:
Code:

INSERT
IGNORE INTO `temp_article`(`code`, `article_id`, `name`)
VALUES ('F', '599908010012', 'this') ,('11', '599908010014', 'that') ,('12', '599908010018', 'whatever');


This would be the goal:
Code:

INSERT IGNORE INTO `temp_article`(`code`, `article_id`, `name`)
    VALUES ('F', '599908010012', 'this')
          ,('11', '599908010014', 'that')
          ,('12','599908010018', 'whatever');


Instead, I get this:
Code:

INSERT IGNORE INTO `temp_article`(`code`, `article_id`, `name`)
    VALUES ('F', '599908010012', 'this')
          ,('11'
          ,'599908010014'
          ,'that')
          ,('12'
          ,'599908010018'
          ,'whatever');


The first item in the row of values is formatting as expected but all the rest are just broken into separate lines at the first possible comma. At first, I thought that there was some interference, probably by the rule for parenthesis, but as it is set to this below, my "educated guess" was that really shouldn't matter. If anything at all, it should make the result more likely to resemble the expected goal. To err on the safe side I disabled that rule. It turned out my guess was right. It did not matter. Anyway, following the rule (disabled) for parenthesis:
Code:
 
(..., ... AND ... OR ...)


Now, if I only select/format the code with the parentheses, the result is what I wanted (well, except for the missing VALUES keyword). Check this short video here.
Fri Aug 13, 2021 1:28 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7847

Post Reply with quote
I'm afraid you are stretching the limits of the pattern based matching and code formatting

The values referenced in the INSERT are like "('F', '599908010012', 'this')" which isn't like pairs of values below

Code:
VALUES (..., ...)
          ,(..., ...);


Then there is also comma specific rule requiring leading commas in every line with everything else wrapped at the next comma occurrence. I bet that overwhelms the formatter causing it to chose something unexpected.
Fri Aug 13, 2021 3:43 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.