Repository navigation
Compare money and decimal values by value when matching - #31
Merged
Merged
Conversation
A decimal keeps its scale, so 4999.0000 and 4999.00 are equal but print differently. A data file holds the source environment's scale, and the target returns its own, which for money follows that environment's precision settings. The match comparison used ToString(), so: - a record with a money or decimal column was never identical, and was updated on every import; - a Match on such a column found nothing, and the record was created a second time. TargetAttributeValue now compares decimals by value, the same way it compares dates since the previous fix. The identical check and the PreRetrieveAll match keys share it.
…s-by-value # Conflicts: # README.md # XTB/ShuffleDeployer.nuspec # XTB/ShuffleRunner.nuspec
…s-by-value # Conflicts: # XTB/ShuffleDeployer.nuspec # XTB/ShuffleRunner.nuspec
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.
Money and decimal values with a different number of decimals never matched, so records with an amount were updated on every import, and a
Matchon an amount created the record again on every run.The cause
A .NET
decimalkeeps its scale:4999.0000and4999.00are equal but print differently. A data file holds the source environment's scale, and the target returns its own, which for money follows that environment's precision settings.TargetAttributeValuecomparedToString()of both.The fix
TargetAttributeValuenow compares decimals by value (ComparableDecimal), the same way it compares dates since #26. Money arrives there as its decimal value. The identical check and thePreRetrieveAllmatch keys share the comparison, so they still agree.Tests
4999.0000against4999,0.0000against0,-12.5000against-12.5. The same goes for a decimal column (1.2500000000against1.25).Matchon a money column finds the existing record instead of creating a duplicate.Without the fix, 5 of the 6 fail; the match test creates a second record. All 278 tests pass in Debug and Release.
Also checked against a real environment: importing a block matched on two money columns twice used to create every record again. With the fix, the second run skips them all.
Fixes #30