 |
SoftTree Technologies
Technical Support Forums
|
|
Author |
Message |
PurpleDog
Joined: 22 Jan 2014 Posts: 6 Country: United Kingdom |
|
Commas in lists (v6.5.278) |
|
Is there a way to have stacked, leading commas but not the totally broken results it gives in functions, lists etc.:
 |
 |
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:
 |
 |
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 |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
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 |
|
 |
gemisigo
Joined: 11 Mar 2010 Posts: 2165
|
|
|
|
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 |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
 |
 |
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 |
|
 |
PurpleDog
Joined: 22 Jan 2014 Posts: 6 Country: United Kingdom |
|
|
|
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 |
|
 |
|
|
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
|
|
|