Repository navigation
Conversation
Neither had a value converter, so a parameter declared with one was sent
as ToString() in the current culture: "1234,5" under fr-FR, stored as such
in a VARCHAR column and refused by a DOUBLE one. A decimal value now infers
DbType.Decimal, as the ADO.NET inference table and GetSchema("DataTypes")
say, instead of DbType.Currency.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Coverage Report for CI Build 39939109057Coverage increased (+0.08%) to 92.874%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats💛 - Coveralls |
This branch is waiting to be deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
DbType.DecimalandDbType.DateTime2have no entry inClrToDuckDBConverter.ValueCreators. A parameter declared with either type falls through toNativeMethods.Value.DuckDBCreateVarchar(item.ToString()), so the value is sent as text in the current culture. Underfr-FRorde-DE, a declared decimal is sent as1234,5:de-DE)DbType.Decimal,Value = 1234.5mINSERTinto aVARCHARcolumn1234,5INSERTinto aDOUBLEcolumnConversion Error: Could not convert string '1234,5' to DOUBLESELECT ?1234,5, not adecimalA
DECIMALcolumn is not affected, because the target type routes the value through(DuckDBType.Decimal, decimal value)first.Today this mostly stays hidden because a decimal value infers
DbType.Currency, which does have a converter. Once #369 lets an explicitDbTypesurvive assigningValue, every caller that setsDbType.Decimalhits this path.Changes
DbType.Decimalgets a converter: adecimalis sent as a DECIMAL, exactly likeDbType.Currency. Any other value keeps the previous fallback, soDbType.Decimalwith anintstill works.DbType.DateTime2is sent likeDbType.DateTime(a TIMESTAMP). Any other value keeps the previous fallback.decimalvalue now infersDbType.Decimalinstead ofDbType.Currency. This matches the ADO.NET inference table and DuckDB.NET's ownGetSchema("DataTypes")(Support ADO.NET schema data types and metadata probing #364), which mapsDECIMALtoSystem.Decimal. Binding does not change: both types send the same DECIMAL value, andDbType.Currencykeeps working when set explicitly.Tests
DecimalValueInfersDbTypeDecimalExplicitDecimalDbTypeIsSentAsADecimalInAnyCulture(DecimalandCurrency, underfr-FR:SELECT ?, aVARCHARcolumn and aDOUBLEcolumn)ExplicitDecimalDbTypeWithAnIntegerValueIsStillSentExplicitDateTime2DbTypeIsSentAsATimestampInAnyCulture(de-DE)ExplicitDateTime2DbTypeWithATextValueIsStillSentThree tests failed before the change (the inference, the
Decimalcase andDateTime2); theCurrencycase and the two fallback guards passed before and after. The fullDuckDB.NET.Testsuite passes locally (net8.0), including the connection stress tests, because the change touchesPreparedStatement/. The new tests passed 5 runs in a row.Found by
pengdows.AdoNetApiTest.conformance(Bind_works_with_values_of_their_own_DbType_in_any_culture,DbType_is_inferred_from_Value).🤖 Generated with Claude Code