terrajobst / nquery-vnext

A Roslyn inspired rewrite of NQuery
MIT License
72 stars 16 forks source link

Make all built-in functions use invariant culture and add overloads for other cultures #57

Closed dallmair closed 2 years ago

dallmair commented 2 years ago

Here's a proposal for the culture-dependent built-in function discussion in #24.

First, all built-in functions should be invariant, including LOWER, UPPER, CHARINDEX, and FORMAT.

Second, new overloads for all culture-dependent function implementations allow users to request specific cultures explicitly. This even allows processing of input where some variable or table column data flows through the system in a different format than others do. Sample usage: FORMAT(5, 'e', 'de-DE') or TO_DECIMAL('5,0', 'de-DE')

Fixes #24.

dallmair commented 2 years ago

There's one thing I'm not sure about with these new overloads. As you can see in the tests, TO_DATETIME(value, culture) can be pretty handy in international contexts, so on one hand I'd like to see it in. On the other hand, I'd also see quite some value in TO_DATETIME(value, format) such that we could write things like TO_DATETIME(value, 'yyyyMMdd'), for example. But having both overloads is a bad idea as they would conflict (at least semantically) and therefore be confusing. Only solution I see is to give a different name to one of them, but I can't come up with a good name.

Thoughts? Ideas?

dallmair commented 2 years ago

In SQL Server, there's also the PARSE function that allows specifying a culture: https://docs.microsoft.com/en-us/sql/t-sql/functions/parse-transact-sql