Skip to content

Commit

Permalink
Quote PK literal in backfill operation
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-farries committed Dec 5, 2023
1 parent b023378 commit 53cdf05
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/migrations/backfill.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func backfill(ctx context.Context, conn *sql.DB, table *schema.Table, cbs ...Cal
type batcher struct {
table *schema.Table
pkColumn *schema.Column
lastPK interface{}
lastPK *string
batchSize int
}

Expand Down Expand Up @@ -85,7 +85,7 @@ func (b *batcher) updateBatch(ctx context.Context, conn *sql.DB) error {
func (b *batcher) buildQuery() string {
whereClause := ""
if b.lastPK != nil {
whereClause = fmt.Sprintf("WHERE %s > %v", pq.QuoteIdentifier(b.pkColumn.Name), b.lastPK)
whereClause = fmt.Sprintf("WHERE %s > %v", pq.QuoteIdentifier(b.pkColumn.Name), pq.QuoteLiteral(*b.lastPK))
}

return fmt.Sprintf(`
Expand Down

0 comments on commit 53cdf05

Please sign in to comment.