refactor: enhance SQL query formatting for PostgreSQL compatibility in dry run and validation processes

This commit is contained in:
2026-05-29 16:01:25 -05:00
parent 86258718d8
commit aa34f66e0b
2 changed files with 73 additions and 20 deletions

View File

@@ -8,6 +8,7 @@ import (
"git.ksdemosapps.com/kylesoda/go-migrate/internal/app/azure"
"git.ksdemosapps.com/kylesoda/go-migrate/internal/app/config"
dbwrapper "git.ksdemosapps.com/kylesoda/go-migrate/internal/app/db-wrapper"
db_dialects "git.ksdemosapps.com/kylesoda/go-migrate/internal/app/db-wrapper/db_dialects"
log "github.com/sirupsen/logrus"
)
@@ -67,9 +68,15 @@ func dryRunCountSourceRows(
for range maxParallelWorkers {
wg.Go(func() {
for job := range chJobs {
var sourceTableDisplay string
if sourceDb.GetDialect() == db_dialects.Postgres {
sourceTableDisplay = fmt.Sprintf(`"%s"."%s"`, job.SourceTable.Schema, job.SourceTable.Table)
} else {
sourceTableDisplay = fmt.Sprintf("[%s].[%s]", job.SourceTable.Schema, job.SourceTable.Table)
}
res := DryRunResult{
JobName: job.Name,
SourceTable: fmt.Sprintf("[%s].[%s]", job.SourceTable.Schema, job.SourceTable.Table),
SourceTable: sourceTableDisplay,
}
count, err := countSourceRows(ctx, sourceDb, job)
if err != nil {