Skip to content

Commit

Permalink
fix: do nothing on insert conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
thoas committed Jan 22, 2024
1 parent bf82328 commit c4558e0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion dialect/postgres/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ func (d *PGDialect) insert(ctx context.Context, table dialect.Table, data map[st

query, args := lk.Insert(table.Name).
Set(pairs...).
OnConflict(table.PrimaryKeyColumnName(), lk.DoUpdate(pairs...)).
OnConflict(table.PrimaryKeyColumnName(), lk.DoNothing()).
Query()
if err := d.exec(ctx, query, args...); err != nil {
return fmt.Errorf("unable to insert %v+ to %s:%w", pairs, table.Name, err)
Expand Down
4 changes: 3 additions & 1 deletion etl/extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ func (e *extractor) handleReferenceKeys(ctx context.Context, depth int, table di
Query()

e.logger.Debug(depthF(depth+1, "Fetch reference key"),
zap.String("reference_key", fmt.Sprintf("%s = %v", referenceKey, value)))
zap.String("reference_key", fmt.Sprintf("%s = %v", referenceKey, value)),
zap.String("table_name", table.Name),
)

if _, err := e.handle(ctx, depth+2, e.schema[referenceKey.Table.Name], query, args...); err != nil {
return fmt.Errorf("unable to handle table %s (query: %s, args: %v): %w", referenceKey.Table.Name, query, args, err)
Expand Down

0 comments on commit c4558e0

Please sign in to comment.