querybuilder icon indicating copy to clipboard operation
querybuilder copied to clipboard

Error in test suite

Open mconca-kube opened this issue 3 years ago • 3 comments

I found an error in the test suite for single/double values, here: https://github.com/sqlkata/querybuilder/blob/422878cd703d75e245e023de89d2ac2ab693f554/QueryBuilder.Tests/ParameterTypeTests.cs#L25 and here: https://github.com/sqlkata/querybuilder/blob/422878cd703d75e245e023de89d2ac2ab693f554/QueryBuilder.Tests/ParameterTypeTests.cs#L27

You convert the string to a Single, using InvariantCulture: OK After that you convert the Single value to string, using ToString(), but without specifying the culture. It should be like this: new object[] {Convert.ToSingle("10.5", CultureInfo.InvariantCulture).ToString(CultureInfo.InvariantCulture), 10.5}

If you run this test on a machine that has a culture with a differente decimal separator like comma, the test would expect the query to be compiled with value "10,5". The query instead compiles correctly with "10.5" and the test fails.

mconca-kube avatar Apr 09 '21 08:04 mconca-kube

Thanks for reporting, would you mind adding a PR for this?

ahmad-moussawi avatar May 22 '21 14:05 ahmad-moussawi

@mconca-kube I think you opened the merge request on the wrong repository ;)

Just a quick follow up on that: Wouldn't it be sufficient to just check for "10.5" and "-2.8" as a string, since the over complicated construct will always evaluate to these values, right?

alexsee avatar Jun 29 '21 06:06 alexsee

Hi there Also found this error, but I think it can be solve like this: new object[] {"10.5", 10.5}, new object[] {"-2.8", -2.8},

nester-a avatar Dec 12 '23 19:12 nester-a