SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
Commas in lists (v6.5.278)

 
Reply to topic    SoftTree Technologies Forum Index » SQL Assistant View previous topic
View next topic
Commas in lists (v6.5.278)
Author Message
PurpleDog



Joined: 22 Jan 2014
Posts: 6
Country: United Kingdom

Post Commas in lists (v6.5.278) Reply with quote
Is there a way to have stacked, leading commas but not the totally broken results it gives in functions, lists etc.:
Code:

                        WHEN v.ManufactureYear BETWEEN 1900 AND 2100
                            THEN DATEADD(
                                     DAY
                                    ,COALESCE (v.ManufactureDay ,1) - 1
                                    ,DATEADD(
                                         MONTH
                                        ,COALESCE (v.ManufactureMonth ,1) - 1
                                        ,CAST (CAST (v.ManufactureYear AS VARCHAR) + '0101' AS DATE)
                                     )
                                 )


All I want is to have that 'corrected' to:

Code:

                        WHEN v.ManufactureYear BETWEEN 1900 AND 2100
                            THEN DATEADD(
                                     DAY
                                    ,COALESCE (v.ManufactureDay, 1) - 1
                                    ,DATEADD(
                                         MONTH
                                        ,COALESCE (v.ManufactureMonth, 1) - 1
                                        ,CAST (CAST (v.ManufactureYear AS VARCHAR) + '0101' AS DATE)
                                     )
                                 )


...it seems like a bug to me, but I guess some people might like the space before the comma in the function call, but if so there should be a way to override that and return to the normal way of using commas. It's a tiny thing but it's driving me mad, almost into the arms of RedGate SQL Prompt!!
Does anyone have a solution? I hope I'm just being dumb and missing something obvious?
Fri Jul 04, 2014 12:22 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7849

Post Reply with quote
This is not a bug. you have a rule for commas it applies them to all lists, but then applies more rules.

To see what I mean, create a new formatting rule in Options for COALESCE with the format you want COALESCE(..., ...)
Fri Jul 04, 2014 4:19 pm View user's profile Send private message
gemisigo



Joined: 11 Mar 2010
Posts: 2109

Post Reply with quote
Wouldn't adding just a rule (..., ...) suffice? I mean, adding a rule for every function would be an enormous task.
Fri Jul 04, 2014 4:35 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7849

Post Reply with quote
gemisigo wrote:
Wouldn't adding just a rule (..., ...) suffice? I mean, adding a rule for every function would be an enormous task.


I'm not certain, but I think it might have the same kind of generic effect, and apply to INSERT and other things with lists, diminishing the original concern for having different formatting rules applied to comma separated lists in different situations. Yet, it may work well for the poster of the original message. also it's possible to setup several different formatting styles and use different styles in different situations.

To PurpleDog - please give a try to the above suggestion and see if it works for you.
Sat Jul 05, 2014 12:39 pm View user's profile Send private message
PurpleDog



Joined: 22 Jan 2014
Posts: 6
Country: United Kingdom

Post Reply with quote
Thanks for the responses...

I initially tried a new COALESCE rule, and that worked, so thanks for that suggestion. Gemisigo is correct though, that adding a rule for every function would be way too much, so I've been attempting to find a generic way to sort this out, with limited success. Everything I do seems to have strange unexpected consequences elsewhere!

I changed the (...) rule to (..., ...), which was mostly OK but left functions sometimes having a space before the bracket and sometimes not, so I added a new function rule
... (..., ...) which worked for most, but some now have two spaces before the bracket, so I've had to add specific rules for the transgressors.

I'm having trouble with various other bits too but having spent half a day on this I've come to the conclusion that when I get bored of refining the rules and discovering their unintended and unexpected interactions (and once I've eliminated the most common irritations)) I just need to reformat once then fix it by hand!
Mon Jul 07, 2014 6:49 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.