diff --git a/tpl/macros_struct.twig b/tpl/macros_struct.twig index c8f1847..e6344b4 100644 --- a/tpl/macros_struct.twig +++ b/tpl/macros_struct.twig @@ -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