Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix: spanner find migration history list query sql (#5051)

p0ny917db915cfb6
diff --git a/backend/plugin/db/spanner/migrate.go b/backend/plugin/db/spanner/migrate.go
index f0412ebda9..6b04944eab 100644
--- a/backend/plugin/db/spanner/migrate.go
+++ b/backend/plugin/db/spanner/migrate.go
@@ -312,7 +312,10 @@ func (d *Driver) FindMigrationHistoryList(ctx context.Context, find *db.Migratio
where = append(where, "version = @version")
params["version"] = storedVersion
}
- query = fmt.Sprintf("%s WHERE %s ORDER BY namespace, sequence DESC", query, strings.Join(where, " AND "))
+ if len(where) != 0 {
+ query = fmt.Sprintf("%s WHERE %s", query, strings.Join(where, " AND "))
+ }
+ query = fmt.Sprintf("%s ORDER BY namespace, sequence DESC", query)
if v := find.Limit; v != nil {
query += fmt.Sprintf(" LIMIT %d", *v)
}