changed collection diff logic so it skips items where only primary ids changed
This commit is contained in:
parent
077ff32925
commit
be6af575c3
|
@ -19,7 +19,7 @@
|
|||
{% macro decl_struct(o, extra = '') %}
|
||||
|
||||
{% set pkey_fields = token(o, 'table_pkey')|split(',') %}
|
||||
{% set pkey = o.fields|filter(f => f.name in pkey_fields ) %}
|
||||
{% set pkey = pkey_fields|filter(f => f|length > 0)|map(f => o.getField(f)) %}
|
||||
|
||||
{%- if o.parent and has_token(o, 'POD') -%}
|
||||
{{Error("@POD structs can't have a parent: " ~ o.name)}}
|
||||
|
@ -128,7 +128,12 @@ public class {{o.name}}Comparer : IComparer<{{o.name}}>
|
|||
{
|
||||
int result;
|
||||
|
||||
{% for f in pkey %}
|
||||
{% set comparable = pkey %}
|
||||
{% if comparable|length > 1 %}
|
||||
{% set comparable = comparable [1:] %}
|
||||
{% endif %}
|
||||
|
||||
{% for f in comparable %}
|
||||
{% if not loop.first %}
|
||||
if(result == 0)
|
||||
{% endif %}
|
||||
|
@ -272,14 +277,34 @@ base.SyncFields(ctx);
|
|||
}
|
||||
|
||||
public void SetPrimaryFieldsChanged()
|
||||
{
|
||||
SetPrimaryFieldsChanged(ref this.fields_mask);
|
||||
}
|
||||
|
||||
static void SetPrimaryFieldsChanged(ref FieldsMask mask)
|
||||
{
|
||||
{%- for f in o.fields ~%}
|
||||
{%- if is_primary_field(o, f) ~%}
|
||||
MetaIO.SetFieldDirty(ref fields_mask, {{loop.index0}});
|
||||
MetaIO.SetFieldDirty(ref mask, {{loop.index0}});
|
||||
{%- endif -%}
|
||||
{%- endfor ~%}
|
||||
}
|
||||
|
||||
public bool IsContentDirty()
|
||||
{
|
||||
int fields_amount = {{fields_count(o)}};
|
||||
var primary_id_mask = FieldsMask.MakeClean(fields_amount);
|
||||
SetPrimaryFieldsChanged(ref primary_id_mask);
|
||||
for(int i = 0; i < fields_amount; i++)
|
||||
{
|
||||
bool is_primary_id = primary_id_mask.IsDirty(i);
|
||||
if(!is_primary_id && fields_mask.IsDirty(i))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void SetDirtyMask()
|
||||
{
|
||||
fields_mask = FieldsMask.MakeDirty(fields_amount: {{fields_count(o)}});
|
||||
|
@ -426,7 +451,7 @@ public class {{o.name}} : IRpc
|
|||
}
|
||||
else
|
||||
{
|
||||
if(!{{_self.compare_func_name(u)}}(ref item, old))
|
||||
if(!{{_self.compare_func_name(u)}}(ref item, old) && item.IsContentDirty())
|
||||
{
|
||||
if(changed != null)
|
||||
changed.Add(item);
|
||||
|
|
Loading…
Reference in New Issue