Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions internal/storage/postgres/utils/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func SnapshotQuery(sl squirrel.SelectBuilder, value uint64, snapshotValue string
// based on the provided value, which represents a transaction ID.
func GenerateGCQuery(table string, value uint64) squirrel.DeleteBuilder {
// Create a Squirrel DELETE builder for the specified table.
deleteBuilder := squirrel.Delete(table)
deleteBuilder := squirrel.StatementBuilder.PlaceholderFormat(squirrel.Dollar).Delete(table)

// Create an expression to check if 'expired_tx_id' is not equal to ActiveRecordTxnID (expired records).
expiredNotActiveExpr := squirrel.Expr("expired_tx_id <> ?::xid8", ActiveRecordTxnID)
Expand All @@ -104,7 +104,7 @@ func GenerateGCQuery(table string, value uint64) squirrel.DeleteBuilder {
// based on the provided value, which represents a transaction ID.
func GenerateGCQueryForTenant(table, tenantID string, value uint64) squirrel.DeleteBuilder {
// Create a Squirrel DELETE builder for the specified table.
deleteBuilder := squirrel.Delete(table)
deleteBuilder := squirrel.StatementBuilder.PlaceholderFormat(squirrel.Dollar).Delete(table)

// Create an expression to check if 'expired_tx_id' is not equal to ActiveRecordTxnID (expired records).
expiredNotActiveExpr := squirrel.Expr("expired_tx_id <> ?::xid8", ActiveRecordTxnID)
Expand Down
4 changes: 2 additions & 2 deletions internal/storage/postgres/utils/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ var _ = Describe("Common", func() {
sql, args, err := query.ToSql()
Expect(err).ShouldNot(HaveOccurred())

expectedSQL := "DELETE FROM relation_tuples WHERE expired_tx_id <> ?::xid8 AND expired_tx_id < ?::xid8"
expectedSQL := "DELETE FROM relation_tuples WHERE expired_tx_id <> $1::xid8 AND expired_tx_id < $2::xid8"
Expect(expectedSQL).Should(Equal(sql))
Expect(args).Should(Equal([]interface{}{utils.ActiveRecordTxnID, uint64(100)}))
})
Expand All @@ -85,7 +85,7 @@ var _ = Describe("Common", func() {
sql, args, err := query.ToSql()
Expect(err).ShouldNot(HaveOccurred())

expectedSQL := "DELETE FROM relation_tuples WHERE tenant_id = ? AND expired_tx_id <> ?::xid8 AND expired_tx_id < ?::xid8"
expectedSQL := "DELETE FROM relation_tuples WHERE tenant_id = $1 AND expired_tx_id <> $2::xid8 AND expired_tx_id < $3::xid8"
Expect(expectedSQL).Should(Equal(sql))
Expect(args).Should(Equal([]interface{}{"tenant1", utils.ActiveRecordTxnID, uint64(100)}))
})
Expand Down