feat: add ORDER BY clause to SQL extract queries for consistent result ordering
This commit is contained in:
@@ -28,7 +28,7 @@ func buildExtractQueryMssql(job MigrationJob, columns []ColumnType) string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return fmt.Sprintf(`SELECT %s FROM [%s].[%s] WITH (NOLOCK)`, sbColumns.String(), job.Schema, job.Table)
|
return fmt.Sprintf(`SELECT %s FROM [%s].[%s] ORDER BY [%s] ASC`, sbColumns.String(), job.Schema, job.Table, job.PrimaryKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildExtractQueryPostgres(job MigrationJob, columns []ColumnType) string {
|
func buildExtractQueryPostgres(job MigrationJob, columns []ColumnType) string {
|
||||||
@@ -56,5 +56,5 @@ func buildExtractQueryPostgres(job MigrationJob, columns []ColumnType) string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return fmt.Sprintf(`SELECT %s FROM "%s"."%s"`, sbColumns.String(), job.Schema, job.Table)
|
return fmt.Sprintf(`SELECT %s FROM "%s"."%s" ORDER BY "%s" ASC`, sbColumns.String(), job.Schema, job.Table, job.PrimaryKey)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,12 +7,14 @@ import (
|
|||||||
type MigrationJob struct {
|
type MigrationJob struct {
|
||||||
Schema string
|
Schema string
|
||||||
Table string
|
Table string
|
||||||
|
PrimaryKey string
|
||||||
}
|
}
|
||||||
|
|
||||||
var migrationJobs []MigrationJob = []MigrationJob{
|
var migrationJobs []MigrationJob = []MigrationJob{
|
||||||
{
|
{
|
||||||
Schema: "Cartografia",
|
Schema: "Cartografia",
|
||||||
Table: "MANZANA",
|
Table: "MANZANA",
|
||||||
|
PrimaryKey: "GDB_ARCHIVE_OID",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user