Remove last comma from values
This commit is contained in:
parent
63d80c1f08
commit
3e942c2e7d
|
@ -215,7 +215,8 @@ func Save{{ ctx.s.name }}Diff(ctx context.Context, dbe metadb.Execer, rec {{ ctx
|
|||
}
|
||||
|
||||
func Save{{ ctx.s.name }}CollectionDiff(ctx context.Context, dbe metadb.Execer, recs []{{ ctx.s.name }}) error {
|
||||
byFieldsKey := map[string]queryDiffBuilder{}
|
||||
byFieldsKey := map[string]*queryDiffBuilder{}
|
||||
|
||||
for _, rec := range recs {
|
||||
if rec.changedFields.Empty() {
|
||||
continue
|
||||
|
@ -238,7 +239,7 @@ func Save{{ ctx.s.name }}CollectionDiff(ctx context.Context, dbe metadb.Execer,
|
|||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
byFieldsKey[key] = builder
|
||||
byFieldsKey[key] = &builder
|
||||
}
|
||||
|
||||
builder := byFieldsKey[key]
|
||||
|
@ -298,13 +299,9 @@ func Save{{ ctx.s.name }}CollectionDiff(ctx context.Context, dbe metadb.Execer,
|
|||
}
|
||||
|
||||
for _, builder := range byFieldsKey {
|
||||
var index int = 1
|
||||
if len(builder.rawValues) > 1 {
|
||||
index = 2
|
||||
}
|
||||
queryBuilder := builder.query
|
||||
builder.query.WriteRune(')')
|
||||
queryBuilder.WriteString(builder.values.String()[0 : len(builder.values.String())-index])
|
||||
queryBuilder := builder.query
|
||||
queryBuilder.WriteString(builder.values.String()[0:len(builder.values.String())-1])
|
||||
queryBuilder.WriteString(builder.update.String())
|
||||
|
||||
_, saveErr := dbe.ExecContext(ctx, queryBuilder.String(), builder.rawValues...)
|
||||
|
|
Loading…
Reference in New Issue