From 7cf728304108a66909e12581bc2a2a5ab1844afe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Boris=20St=C3=A4heli?= Date: Mon, 16 Nov 2026 16:40:09 +0100 Subject: [PATCH 1/3] Decimal storage: pin observed BC behavior Add measured probes for persisted precision, key/filter lookups, unique collisions, and temporary records across BC 27.5, 28.5, and 29.1. Session: act-on-feedback-issue-7866 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../record/crud/DecimalStorageUnique.Table.al | 22 ++ tests/al-language/record/crud/RcAGetFind.al | 264 +++++++++++++++++- 2 files changed, 283 insertions(+), 3 deletions(-) create mode 100644 tests/al-language/record/crud/DecimalStorageUnique.Table.al diff --git a/tests/al-language/record/crud/DecimalStorageUnique.Table.al b/tests/al-language/record/crud/DecimalStorageUnique.Table.al new file mode 100644 index 000000000..2ee802122 --- /dev/null +++ b/tests/al-language/record/crud/DecimalStorageUnique.Table.al @@ -0,0 +1,22 @@ +// BC Documentation: https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/properties/devenv-unique-property +// Scope: in-scope +// Fixtures used: local table with an Integer primary key and a unique Decimal secondary key. +// Probe: collisions after Decimal storage are rejected on BC 27.5, 28.5 and 29.1. +// BC versions: 27, 28, 29 +// local object: the probe needs a unique secondary key on a Decimal field. +table 70000 "REC Decimal Unique" +{ + DataClassification = SystemMetadata; + + fields + { + field(70000; Id; Integer) { } + field(1; Amount; Decimal) { } + } + + keys + { + key(PK; Id) { Clustered = true; } + key(UniqueAmount; Amount) { Unique = true; } + } +} diff --git a/tests/al-language/record/crud/RcAGetFind.al b/tests/al-language/record/crud/RcAGetFind.al index 675b5bbf9..c860c979c 100644 --- a/tests/al-language/record/crud/RcAGetFind.al +++ b/tests/al-language/record/crud/RcAGetFind.al @@ -1,8 +1,8 @@ // BC Documentation: https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/record/record-data-type // Scope: in-scope -// Fixtures used: LT RcA tables and seed codeunit in RcAObjects.al, Probe Observer (69160) -// Probe: written against a local BC 29.0.54011.55816 service tier; every literal asserted below is what that tier produced. Other BC versions are checked by the corpus CI matrix. -// BC versions: 29 (27 and 28 by CI) +// Fixtures used: LT RcA tables and seed codeunit in RcAObjects.al, Probe Observer (69160), REC Decimal Unique +// Probe: existing tests were written against BC 29.0.54011.55816; DecimalStorage probes were observed on BC 27.5, 28.5 and 29.1. +// BC versions: 27, 28, 29 (DecimalStorage); 29 with 27 and 28 checked by CI (existing tests) codeunit 71500 "LT RcA GetFind" { @@ -714,4 +714,262 @@ codeunit 71500 "LT RcA GetFind" Observer.Expect('count', 'count=1'); Observer.Verify(); end; + + local procedure Initialize() + var + Row: Record "LT RcA Main"; + DecimalKey: Record "LT RcA DecKey"; + UniqueRow: Record "REC Decimal Unique"; + begin + Row.DeleteAll(); + DecimalKey.DeleteAll(); + UniqueRow.DeleteAll(); + end; + + local procedure FormatStoredDecimal(Amount: Decimal) Result: Text + begin + Result := Format((Amount * 100000000000000.0) * 10000.0, 0, 9); + end; + + local procedure ObserveDecimalInsert(EntryNo: Integer; Amount: Decimal) + var + Row: Record "LT RcA Main"; + Stored: Record "LT RcA Main"; + begin + Row.No := EntryNo; + Row.Amt := Amount; + Row.Insert(); + Stored.Get(EntryNo); + Observer.Observe(Format(EntryNo) + '_stored_scaled', FormatStoredDecimal(Stored.Amt)); + Observer.Observe(Format(EntryNo) + '_stored_equal', Format(Stored.Amt = Amount)); + Observer.Observe(Format(EntryNo) + '_buffer_equal', Format(Row.Amt = Amount)); + end; + + [Test] + procedure DecimalStorage_Insert_ReadAndBuffer() + begin + Initialize(); + ObserveDecimalInsert(1, 1000 / 3600000); + ObserveDecimalInsert(2, -1000 / 3600000); + ObserveDecimalInsert(3, 0.000000000000000000019); + ObserveDecimalInsert(4, -0.000000000000000000019); + ObserveDecimalInsert(5, 0.00012345678901234567891); + ObserveDecimalInsert(6, 0.0000123456789012345678); + Observer.Expect('1_stored_scaled', '277777777777777.77'); + Observer.Expect('1_stored_equal', 'No'); + Observer.Expect('1_buffer_equal', 'Yes'); + Observer.Expect('2_stored_scaled', '-277777777777777.77'); + Observer.Expect('2_stored_equal', 'No'); + Observer.Expect('2_buffer_equal', 'Yes'); + Observer.Expect('3_stored_scaled', '0.01'); + Observer.Expect('3_stored_equal', 'No'); + Observer.Expect('3_buffer_equal', 'Yes'); + Observer.Expect('4_stored_scaled', '-0.01'); + Observer.Expect('4_stored_equal', 'No'); + Observer.Expect('4_buffer_equal', 'Yes'); + Observer.Expect('5_stored_scaled', '123456789012345.67'); + Observer.Expect('5_stored_equal', 'No'); + Observer.Expect('5_buffer_equal', 'Yes'); + Observer.Expect('6_stored_scaled', '12345678901234.56'); + Observer.Expect('6_stored_equal', 'No'); + Observer.Expect('6_buffer_equal', 'Yes'); + Observer.Verify(); + end; + + [Test] + procedure DecimalStorage_Modify_ReadAndBuffer() + var + Row: Record "LT RcA Main"; + Stored: Record "LT RcA Main"; + begin + Initialize(); + Row.No := 1; + Row.Insert(); + Row.Amt := 1000 / 3600000; + Row.Modify(); + Stored.Get(1); + Observer.Observe('stored_scaled', FormatStoredDecimal(Stored.Amt)); + Observer.Observe('stored_equal', Format(Stored.Amt = 1000 / 3600000)); + Observer.Observe('buffer_equal', Format(Row.Amt = 1000 / 3600000)); + Observer.Expect('stored_scaled', '277777777777777.77'); + Observer.Expect('stored_equal', 'No'); + Observer.Expect('buffer_equal', 'Yes'); + Observer.Verify(); + end; + + [Test] + procedure DecimalStorage_Filter_FullAndStoredValues() + var + Row: Record "LT RcA Main"; + Full: Decimal; + Cut: Decimal; + begin + Initialize(); + Full := 1000 / 3600000; + Cut := 0.00027777777777777777; + Row.No := 1; + Row.Amt := Full; + Row.Insert(); + Row.SetRange(Amt, Full); + Observer.Observe('equal_full', Format(Row.Count())); + Row.SetRange(Amt, Cut); + Observer.Observe('equal_cut', Format(Row.Count())); + Row.SetFilter(Amt, '<%1', Full); + Observer.Observe('less_full', Format(Row.Count())); + Row.SetFilter(Amt, '<%1', Cut); + Observer.Observe('less_cut', Format(Row.Count())); + Row.SetFilter(Amt, '>%1', Full); + Observer.Observe('greater_full', Format(Row.Count())); + Row.SetFilter(Amt, '>%1', Cut); + Observer.Observe('greater_cut', Format(Row.Count())); + Row.SetRange(Amt, Full, Full); + Observer.Observe('range_full', Format(Row.Count())); + Row.SetRange(Amt, Cut, Cut); + Observer.Observe('range_cut', Format(Row.Count())); + Row.SetRange(Amt, Cut, Full); + Observer.Observe('range_cut_full', Format(Row.Count())); + Observer.Expect('equal_full', '1'); + Observer.Expect('equal_cut', '1'); + Observer.Expect('less_full', '0'); + Observer.Expect('less_cut', '0'); + Observer.Expect('greater_full', '0'); + Observer.Expect('greater_cut', '0'); + Observer.Expect('range_full', '1'); + Observer.Expect('range_cut', '1'); + Observer.Expect('range_cut_full', '1'); + Observer.Verify(); + end; + + [Test] + procedure DecimalStorage_PrimaryKey_InsertAndGet() + var + Row: Record "LT RcA DecKey"; + Found: Record "LT RcA DecKey"; + Full: Decimal; + Cut: Decimal; + begin + Initialize(); + Full := 1000 / 3600000; + Cut := 0.00027777777777777777; + Row.Dc := Full; + Row.Insert(); + Observer.Observe('buffer_equal', Format(Row.Dc = Full)); + Observer.Observe('get_full', Format(Found.Get(Full))); + Observer.Observe('get_cut', Format(Found.Get(Cut))); + if Found.FindFirst() then + Observer.Observe('stored_key_scaled', FormatStoredDecimal(Found.Dc)) + else + Observer.Observe('stored_key_scaled', 'no row'); + Observer.Expect('buffer_equal', 'Yes'); + Observer.Expect('get_full', 'Yes'); + Observer.Expect('get_cut', 'Yes'); + Observer.Expect('stored_key_scaled', '277777777777777.77'); + Observer.Verify(); + end; + + [Test] + procedure DecimalStorage_UniqueSecondary_Collision() + var + Row: Record "REC Decimal Unique"; + Stored: Record "REC Decimal Unique"; + begin + Initialize(); + Row.Id := 1; + Row.Amount := 0.00000000000000000001; + Row.Insert(); + Row.Id := 2; + Row.Amount := 0.000000000000000000019; + Observer.Observe('second_insert', Format(Row.Insert())); + Observer.Observe('buffer_equal', Format(Row.Amount = 0.000000000000000000019)); + Observer.Observe('count', Format(Stored.Count())); + if Stored.FindFirst() then + Observer.Observe('first_amount_scaled', FormatStoredDecimal(Stored.Amount)); + if Stored.FindLast() then + Observer.Observe('last_amount_scaled', FormatStoredDecimal(Stored.Amount)); + Observer.Expect('second_insert', 'No'); + Observer.Expect('buffer_equal', 'Yes'); + Observer.Expect('count', '1'); + Observer.Expect('first_amount_scaled', '0.01'); + Observer.Expect('last_amount_scaled', '0.01'); + Observer.Verify(); + end; + + [Test] + procedure DecimalStorage_UniqueSecondary_Modify() + var + Row: Record "REC Decimal Unique"; + Stored: Record "REC Decimal Unique"; + begin + Initialize(); + Row.Id := 1; + Row.Amount := 0.00000000000000000001; + Row.Insert(); + Row.Id := 2; + Row.Amount := 0.1; + Row.Insert(); + Row.Amount := 0.000000000000000000019; + Observer.Observe('modify', Format(Row.Modify())); + Observer.Observe('buffer_equal', Format(Row.Amount = 0.000000000000000000019)); + Observer.Observe('count', Format(Stored.Count())); + if Stored.Get(2) then + Observer.Observe('stored_amount', Format(Stored.Amount, 0, 9)); + Observer.Expect('modify', 'No'); + Observer.Expect('buffer_equal', 'Yes'); + Observer.Expect('count', '2'); + Observer.Expect('stored_amount', '0.1'); + Observer.Verify(); + end; + + [Test] + procedure DecimalStorage_UniqueSecondary_Rename() + var + Row: Record "REC Decimal Unique"; + Stored: Record "REC Decimal Unique"; + begin + Initialize(); + Row.Id := 1; + Row.Amount := 0.00000000000000000001; + Row.Insert(); + Row.Id := 2; + Row.Amount := 0.1; + Row.Insert(); + Commit(); + Row.Amount := 0.000000000000000000019; + asserterror Row.Rename(3); + Observer.ObserveError('rename_error'); + Observer.Observe('buffer_equal', Format(Row.Amount = 0.000000000000000000019)); + Observer.Observe('count', Format(Stored.Count())); + Observer.Observe('old_id_found', Format(Stored.Get(2))); + if Stored.Get(2) then + Observer.Observe('stored_amount', Format(Stored.Amount, 0, 9)); + Observer.Observe('new_id_found', Format(Stored.Get(3))); + Observer.Expect('rename_error|text', 'There is already a record in table REC Decimal Unique that has the same values in a unique index for the following fields: Amount=''0'''); + Observer.Expect('rename_error|code', 'DB:RecordExists'); + Observer.Expect('buffer_equal', 'Yes'); + Observer.Expect('count', '2'); + Observer.Expect('old_id_found', 'Yes'); + Observer.Expect('stored_amount', '0.1'); + Observer.Expect('new_id_found', 'No'); + Observer.Verify(); + end; + + [Test] + procedure DecimalStorage_Temporary_ReadAndBuffer() + var + Row: Record "LT RcA Main" temporary; + Buffer: Decimal; + begin + Initialize(); + Row.DeleteAll(); + Row.No := 1; + Row.Amt := 1000 / 3600000; + Row.Insert(); + Buffer := Row.Amt; + Row.Get(1); + Observer.Observe('buffer_equal_original', Format(Buffer = 1000 / 3600000)); + Observer.Observe('stored_equal_buffer', Format(Row.Amt = Buffer)); + Observer.Expect('buffer_equal_original', 'Yes'); + Observer.Expect('stored_equal_buffer', 'Yes'); + Observer.Verify(); + end; } From 12c1fd07e0344ec1842448029c7b41f88f5cf889 Mon Sep 17 00:00:00 2001 From: Boris <17029159+bstaeheli@users.noreply.github.com> Date: Tue, 17 Nov 2026 17:01:36 +0100 Subject: [PATCH 2/3] Decimal storage: use four-part test names Use the corpus test naming convention without changing the measured behavior. Session: act-on-feedback-issue-7866 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- tests/al-language/record/crud/RcAGetFind.al | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/al-language/record/crud/RcAGetFind.al b/tests/al-language/record/crud/RcAGetFind.al index c860c979c..df37b0110 100644 --- a/tests/al-language/record/crud/RcAGetFind.al +++ b/tests/al-language/record/crud/RcAGetFind.al @@ -1,8 +1,8 @@ // BC Documentation: https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/record/record-data-type // Scope: in-scope // Fixtures used: LT RcA tables and seed codeunit in RcAObjects.al, Probe Observer (69160), REC Decimal Unique -// Probe: existing tests were written against BC 29.0.54011.55816; DecimalStorage probes were observed on BC 27.5, 28.5 and 29.1. -// BC versions: 27, 28, 29 (DecimalStorage); 29 with 27 and 28 checked by CI (existing tests) +// Probe: existing tests were written against BC 29.0.54011.55816; Decimal storage probes were observed on BC 27.5, 28.5 and 29.1. +// BC versions: 27, 28, 29 (Decimal storage); 29 with 27 and 28 checked by CI (existing tests) codeunit 71500 "LT RcA GetFind" { @@ -746,7 +746,7 @@ codeunit 71500 "LT RcA GetFind" end; [Test] - procedure DecimalStorage_Insert_ReadAndBuffer() + procedure Record_Insert_HighScaleDecimal_TruncatesStoredValue() begin Initialize(); ObserveDecimalInsert(1, 1000 / 3600000); @@ -777,7 +777,7 @@ codeunit 71500 "LT RcA GetFind" end; [Test] - procedure DecimalStorage_Modify_ReadAndBuffer() + procedure Record_Modify_HighScaleDecimal_TruncatesStoredValue() var Row: Record "LT RcA Main"; Stored: Record "LT RcA Main"; @@ -798,7 +798,7 @@ codeunit 71500 "LT RcA GetFind" end; [Test] - procedure DecimalStorage_Filter_FullAndStoredValues() + procedure Record_SetFilter_HighScaleDecimal_UsesStoredPrecision() var Row: Record "LT RcA Main"; Full: Decimal; @@ -841,7 +841,7 @@ codeunit 71500 "LT RcA GetFind" end; [Test] - procedure DecimalStorage_PrimaryKey_InsertAndGet() + procedure Record_Get_HighScaleDecimalKey_UsesStoredPrecision() var Row: Record "LT RcA DecKey"; Found: Record "LT RcA DecKey"; @@ -868,7 +868,7 @@ codeunit 71500 "LT RcA GetFind" end; [Test] - procedure DecimalStorage_UniqueSecondary_Collision() + procedure Record_Insert_UniqueDecimalCollision_ReturnsFalse() var Row: Record "REC Decimal Unique"; Stored: Record "REC Decimal Unique"; @@ -895,7 +895,7 @@ codeunit 71500 "LT RcA GetFind" end; [Test] - procedure DecimalStorage_UniqueSecondary_Modify() + procedure Record_Modify_UniqueDecimalCollision_ReturnsFalse() var Row: Record "REC Decimal Unique"; Stored: Record "REC Decimal Unique"; @@ -921,7 +921,7 @@ codeunit 71500 "LT RcA GetFind" end; [Test] - procedure DecimalStorage_UniqueSecondary_Rename() + procedure Record_Rename_UniqueDecimalCollision_ThrowsRecordExists() var Row: Record "REC Decimal Unique"; Stored: Record "REC Decimal Unique"; @@ -954,7 +954,7 @@ codeunit 71500 "LT RcA GetFind" end; [Test] - procedure DecimalStorage_Temporary_ReadAndBuffer() + procedure Record_Insert_TemporaryDecimal_PreservesPrecision() var Row: Record "LT RcA Main" temporary; Buffer: Decimal; From 41364c1e0b621d81046f876d1ab475ae134b2f60 Mon Sep 17 00:00:00 2001 From: Boris Date: Tue, 24 Nov 2026 11:59:06 +0100 Subject: [PATCH 3/3] test(record): strengthen decimal storage probes Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- tests/al-language/record/crud/RcAGetFind.al | 172 +++++++++++++++++--- 1 file changed, 149 insertions(+), 23 deletions(-) diff --git a/tests/al-language/record/crud/RcAGetFind.al b/tests/al-language/record/crud/RcAGetFind.al index df37b0110..53f262658 100644 --- a/tests/al-language/record/crud/RcAGetFind.al +++ b/tests/al-language/record/crud/RcAGetFind.al @@ -2,6 +2,7 @@ // Scope: in-scope // Fixtures used: LT RcA tables and seed codeunit in RcAObjects.al, Probe Observer (69160), REC Decimal Unique // Probe: existing tests were written against BC 29.0.54011.55816; Decimal storage probes were observed on BC 27.5, 28.5 and 29.1. +// Decimal storage matrix: insert/modify, filter comparisons and ranges, key lookup, unique-key writes, and temporary records. // BC versions: 27, 28, 29 (Decimal storage); 29 with 27 and 28 checked by CI (existing tests) codeunit 71500 "LT RcA GetFind" @@ -745,6 +746,15 @@ codeunit 71500 "LT RcA GetFind" Observer.Observe(Format(EntryNo) + '_buffer_equal', Format(Row.Amt = Amount)); end; + local procedure ObserveDecimalFilter(Name: Text; var Row: Record "LT RcA Main") + begin + Observer.Observe(Name + '_count', Format(Row.Count())); + if Row.FindFirst() then + Observer.Observe(Name + '_first', Format(Row.No)); + if Row.FindLast() then + Observer.Observe(Name + '_last', Format(Row.No)); + end; + [Test] procedure Record_Insert_HighScaleDecimal_TruncatesStoredValue() begin @@ -810,33 +820,57 @@ codeunit 71500 "LT RcA GetFind" Row.No := 1; Row.Amt := Full; Row.Insert(); + Row.No := 2; + Row.Amt := Cut - 0.00000000000000000001; + Row.Insert(); + Row.No := 3; + Row.Amt := Cut + 0.00000000000000000001; + Row.Insert(); Row.SetRange(Amt, Full); - Observer.Observe('equal_full', Format(Row.Count())); + ObserveDecimalFilter('equal_full', Row); Row.SetRange(Amt, Cut); - Observer.Observe('equal_cut', Format(Row.Count())); + ObserveDecimalFilter('equal_cut', Row); Row.SetFilter(Amt, '<%1', Full); - Observer.Observe('less_full', Format(Row.Count())); + ObserveDecimalFilter('less_full', Row); Row.SetFilter(Amt, '<%1', Cut); - Observer.Observe('less_cut', Format(Row.Count())); + ObserveDecimalFilter('less_cut', Row); Row.SetFilter(Amt, '>%1', Full); - Observer.Observe('greater_full', Format(Row.Count())); + ObserveDecimalFilter('greater_full', Row); Row.SetFilter(Amt, '>%1', Cut); - Observer.Observe('greater_cut', Format(Row.Count())); + ObserveDecimalFilter('greater_cut', Row); Row.SetRange(Amt, Full, Full); - Observer.Observe('range_full', Format(Row.Count())); + ObserveDecimalFilter('range_full', Row); Row.SetRange(Amt, Cut, Cut); - Observer.Observe('range_cut', Format(Row.Count())); + ObserveDecimalFilter('range_cut', Row); Row.SetRange(Amt, Cut, Full); - Observer.Observe('range_cut_full', Format(Row.Count())); - Observer.Expect('equal_full', '1'); - Observer.Expect('equal_cut', '1'); - Observer.Expect('less_full', '0'); - Observer.Expect('less_cut', '0'); - Observer.Expect('greater_full', '0'); - Observer.Expect('greater_cut', '0'); - Observer.Expect('range_full', '1'); - Observer.Expect('range_cut', '1'); - Observer.Expect('range_cut_full', '1'); + ObserveDecimalFilter('range_cut_full', Row); + Observer.Expect('equal_full_count', '1'); + Observer.Expect('equal_full_first', '1'); + Observer.Expect('equal_full_last', '1'); + Observer.Expect('equal_cut_count', '1'); + Observer.Expect('equal_cut_first', '1'); + Observer.Expect('equal_cut_last', '1'); + Observer.Expect('less_full_count', '1'); + Observer.Expect('less_full_first', '2'); + Observer.Expect('less_full_last', '2'); + Observer.Expect('less_cut_count', '1'); + Observer.Expect('less_cut_first', '2'); + Observer.Expect('less_cut_last', '2'); + Observer.Expect('greater_full_count', '1'); + Observer.Expect('greater_full_first', '3'); + Observer.Expect('greater_full_last', '3'); + Observer.Expect('greater_cut_count', '1'); + Observer.Expect('greater_cut_first', '3'); + Observer.Expect('greater_cut_last', '3'); + Observer.Expect('range_full_count', '1'); + Observer.Expect('range_full_first', '1'); + Observer.Expect('range_full_last', '1'); + Observer.Expect('range_cut_count', '1'); + Observer.Expect('range_cut_first', '1'); + Observer.Expect('range_cut_last', '1'); + Observer.Expect('range_cut_full_count', '1'); + Observer.Expect('range_cut_full_first', '1'); + Observer.Expect('range_cut_full_last', '1'); Observer.Verify(); end; @@ -852,18 +886,29 @@ codeunit 71500 "LT RcA GetFind" Full := 1000 / 3600000; Cut := 0.00027777777777777777; Row.Dc := Full; + Row.Info := 'target'; Row.Insert(); Observer.Observe('buffer_equal', Format(Row.Dc = Full)); + Row.Dc := 1; + Row.Info := 'other'; + Row.Insert(); Observer.Observe('get_full', Format(Found.Get(Full))); + Observer.Observe('full_key_scaled', FormatStoredDecimal(Found.Dc)); + Observer.Observe('full_info', Found.Info); + Clear(Found); Observer.Observe('get_cut', Format(Found.Get(Cut))); - if Found.FindFirst() then - Observer.Observe('stored_key_scaled', FormatStoredDecimal(Found.Dc)) - else - Observer.Observe('stored_key_scaled', 'no row'); + Observer.Observe('cut_key_scaled', FormatStoredDecimal(Found.Dc)); + Observer.Observe('cut_info', Found.Info); + Clear(Found); + Observer.Observe('get_missing', Format(Found.Get(0.000000000000000000019))); Observer.Expect('buffer_equal', 'Yes'); Observer.Expect('get_full', 'Yes'); + Observer.Expect('full_key_scaled', '277777777777777.77'); + Observer.Expect('full_info', 'target'); Observer.Expect('get_cut', 'Yes'); - Observer.Expect('stored_key_scaled', '277777777777777.77'); + Observer.Expect('cut_key_scaled', '277777777777777.77'); + Observer.Expect('cut_info', 'target'); + Observer.Expect('get_missing', 'No'); Observer.Verify(); end; @@ -972,4 +1017,85 @@ codeunit 71500 "LT RcA GetFind" Observer.Expect('stored_equal_buffer', 'Yes'); Observer.Verify(); end; + + [Test] + procedure Record_Insert_UniqueHighScaleDecimal_StoresTruncatedValue() + var + Row: Record "REC Decimal Unique"; + Stored: Record "REC Decimal Unique"; + Amount: Decimal; + begin + Initialize(); + Amount := 1000 / 3600000; + Row.Id := 1; + Row.Amount := 0.1; + Row.Insert(); + Row.Id := 2; + Row.Amount := Amount; + Observer.Observe('insert', Format(Row.Insert())); + Observer.Observe('buffer_equal', Format(Row.Amount = Amount)); + Observer.Observe('found', Format(Stored.Get(2))); + Observer.Observe('stored_scaled', FormatStoredDecimal(Stored.Amount)); + Observer.Expect('insert', 'Yes'); + Observer.Expect('buffer_equal', 'Yes'); + Observer.Expect('found', 'Yes'); + Observer.Expect('stored_scaled', '277777777777777.77'); + Observer.Verify(); + end; + + [Test] + procedure Record_Modify_UniqueHighScaleDecimal_StoresTruncatedValue() + var + Row: Record "REC Decimal Unique"; + Stored: Record "REC Decimal Unique"; + Amount: Decimal; + begin + Initialize(); + Amount := 1000 / 3600000; + Row.Id := 1; + Row.Amount := 0.1; + Row.Insert(); + Row.Id := 2; + Row.Amount := 0.2; + Row.Insert(); + Row.Amount := Amount; + Observer.Observe('modify', Format(Row.Modify())); + Observer.Observe('buffer_equal', Format(Row.Amount = Amount)); + Observer.Observe('found', Format(Stored.Get(2))); + Observer.Observe('stored_scaled', FormatStoredDecimal(Stored.Amount)); + Observer.Expect('modify', 'Yes'); + Observer.Expect('buffer_equal', 'Yes'); + Observer.Expect('found', 'Yes'); + Observer.Expect('stored_scaled', '277777777777777.77'); + Observer.Verify(); + end; + + [Test] + procedure Record_Rename_UniqueHighScaleDecimal_StoresTruncatedValue() + var + Row: Record "REC Decimal Unique"; + Stored: Record "REC Decimal Unique"; + Amount: Decimal; + begin + Initialize(); + Amount := 1000 / 3600000; + Row.Id := 1; + Row.Amount := 0.1; + Row.Insert(); + Row.Id := 2; + Row.Amount := 0.2; + Row.Insert(); + Row.Amount := Amount; + Observer.Observe('rename', Format(Row.Rename(3))); + Observer.Observe('buffer_equal', Format(Row.Amount = Amount)); + Observer.Observe('old_found', Format(Stored.Get(2))); + Observer.Observe('new_found', Format(Stored.Get(3))); + Observer.Observe('stored_scaled', FormatStoredDecimal(Stored.Amount)); + Observer.Expect('rename', 'Yes'); + Observer.Expect('buffer_equal', 'Yes'); + Observer.Expect('old_found', 'No'); + Observer.Expect('new_found', 'Yes'); + Observer.Expect('stored_scaled', '277777777777777.77'); + Observer.Verify(); + end; }