Closed lemish closed 3 years ago
Thank you for reporting this. Culture based parsing is one of the harder things to notice and troubleshoot.
Can you tell me how T-SQL normally handles numbers in your region? I agree that your submitted change will force always parsing with the assumption of US formatting, regardless of local settings, but then it wouldn't handle parsing 12,34. Is that a valid number in T-SQL, or does T-SQL only accept US format?
I'm pondering Invariant Culture, or allowing the caller to override the US setting if needed.
On machine with non en-US culture (such as ru-RU or uk-UA),
System.Double.Parse()
throws the FormatException if argument is number with point (like "12.34"). That can be easy fixed with adding third argument to methodSystem.Double.Parse().
Value = Double.Parse(Text, NumberStyles.Any);
change to
Value = Double.Parse(Text, NumberStyles.Any, new CultureInfo("en-US"));
https://github.com/bruce-dunwiddie/tsql-parser/blob/cdbb2c6344611e1dfc362c7ec947dceb9bec659a/TSQL_Parser/TSQL_Parser/Tokens/TSQLNumericLiteral.cs#L19