fix saving diff for structs with pk fields only

This commit is contained in:
Pavel Merzlyakov 2023-11-03 20:51:46 +03:00
parent 49efdd1464
commit 857db14448
1 changed files with 2 additions and 1 deletions

View File

@ -149,8 +149,8 @@ func Save{{ ctx.s.name }}Diff(ctx context.Context, dbe metadb.Execer, rec {{ ctx
values = append(values, rec.{{ f|fname }})
{% endfor %}
{% if ctx.raw_nonpk_fields|length > 0 %}
initUpdateLen := updateBuilder.Len()
{% for f in ctx.raw_nonpk_fields %}
if rec.{{ f|fname }}Changed() {
queryBuilder.WriteString(",`{{ f.name }}`")
@ -164,6 +164,7 @@ func Save{{ ctx.s.name }}Diff(ctx context.Context, dbe metadb.Execer, rec {{ ctx
values = append(values, rec.{{ f|fname }})
}
{% endfor %}
{% endif %}
{% if has_token(ctx.s, 'table_json_kv') %}
var jsonBuilder strings.Builder