SqlServerTimeZoneSupport icon indicating copy to clipboard operation
SqlServerTimeZoneSupport copied to clipboard

Handle NULL option as default

Open PinkDuck opened this issue 9 years ago • 2 comments

If NULL is supplied to the @FirstOnFallBackOverlap parameter then the function uses the non-default action instead of the default. For this reason I have added a check for NULL. It is okay for the @SkipOnSpringForwardGap case as there is a test against 0 that requires it to be explicitly set for non-default behaviour.

PinkDuck avatar Feb 17 '16 16:02 PinkDuck

In what case might a NULL be passed explicitly? I see what this is guarding against, but I'm not sure it would actually be encountered.

What I'd really like is a way to not have to pass a value at all, but I don't think this can be accomplished with functions.

mattjohnsonpint avatar Jul 25 '16 05:07 mattjohnsonpint

The usual pattern would be calling with DEFAULT explicitly, but since T-SQL inline variables all all nullable types there's the potential for unintended behaviour. I think many would like properly optional arguments. I see NULL/DEFAULT as similar, with both leaving it to the function to decide the behaviour. It's not so easy on the calling side to dynamically control the value between 0, 1 and DEFAULT without using a NULL-supporting ternary state.

PinkDuck avatar Jul 25 '16 07:07 PinkDuck