Open BravoTango86 opened 6 months ago
@BravoTango86 are you using plv8 based patching or the new inbuilt patching available in the latest beta?
It would help if you could share a repro/sample as well.
Hi @mysticmind
Using the new patching function in v7 - the call to PatchOperation.applyUpdates is unconditional.
public record Test(Guid Id, [property:DuplicateField] string Key, string Value);
var record = new Test(CombGuidIdGeneration.NewGuid(), "test", "Test item");
lightweightSession.Insert(record);
lightweightSession.SaveChanges();
lightweightSession.Patch<Test>(record.Id).Set(r => r.Value, "Test");
lightweightSession.SaveChanges();
Results in:
select public.mt_insert_tests_test($1, $2, $3, $4, $5)
: test
: {"Id":"018dd875-efe0-41ab-b5b8-43b6fbd8c866","Key":"test","Value":"Test item"}
: Demo.Demo+Test
: 018dd875-efe0-41ab-b5b8-43b6fbd8c866
: 018dd875-f41f-4d55-b0a3-bc746bdf6235
Persisted 0 updates in 16 ms, 1 inserts, and 0 deletions
update public.mt_doc_tests_test as d set data = public.mt_jsonb_patch(data, $1), mt_last_modified = (now() at time zone 'utc'), mt_version = $2 where d.id = $3
: [{"type":"set","value":"Test","path":"Value"}]
: 018dd875-f464-4a45-8548-a545c8d906ce
: 018dd875-efe0-41ab-b5b8-43b6fbd8c866
update public.mt_doc_tests_test as d set key = data ->> 'Key' where d.id = $1
: 018dd875-efe0-41ab-b5b8-43b6fbd8c866
Persisted 0 updates in 8 ms, 0 inserts, and 0 deletions
@BravoTango86 Thanks for the details. Looks like the plv8 implementation also has the same issue since that portion code is all the same in terms of implementation. I will troubleshoot and try to fix this.
Excellent, thank you!
Hi @mysticmind
Semi related though happy to submit as a separate issue - PatchFragment doesn't check whether last modified and version columns are disabled.
Hi @mysticmind
Semi related though happy to submit as a separate issue - PatchFragment doesn't check whether last modified and version columns are disabled.
Please go ahead and raise it as a separate issue, will look to fix it.
When undertaking a Patch operation, all duplicated fields are updated even if none have been amended.
Is it at all possible for for this to checked or suppressed?