Skip to content

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

chore: order by resource id (#13108)

Danny Xu79228a1c555f
diff --git a/backend/store/database.go b/backend/store/database.go
index 012f20e666..f62f941810 100644
--- a/backend/store/database.go
+++ b/backend/store/database.go
@@ -535,7 +535,8 @@ func (*Store) listDatabaseImplV2(ctx context.Context, tx *Tx, find *FindDatabase
LEFT JOIN project ON db.project_id = project.id
LEFT JOIN instance ON db.instance_id = instance.id
WHERE %s
- GROUP BY db.id, project.resource_id, instance.resource_id`, strings.Join(where, " AND "))
+ GROUP BY db.id, project.resource_id, instance.resource_id
+ ORDER BY project.resource_id, instance.resource_id, db.name`, strings.Join(where, " AND "))
if v := find.Limit; v != nil {
query += fmt.Sprintf(" LIMIT %d", *v)
}
diff --git a/backend/store/instance.go b/backend/store/instance.go
index 5e6a980af3..01bd19f698 100644
--- a/backend/store/instance.go
+++ b/backend/store/instance.go
@@ -395,7 +395,7 @@ func (s *Store) listInstanceImplV2(ctx context.Context, tx *Tx, find *FindInstan
}
var instanceMessages []*InstanceMessage
- rows, err := tx.QueryContext(ctx, `
+ rows, err := tx.QueryContext(ctx, fmt.Sprintf(`
SELECT
id,
resource_id,
@@ -409,7 +409,8 @@ func (s *Store) listInstanceImplV2(ctx context.Context, tx *Tx, find *FindInstan
options,
metadata
FROM instance
- WHERE `+strings.Join(where, " AND "),
+ WHERE %s
+ ORDER BY resource_id`, strings.Join(where, " AND ")),
args...,
)
if err != nil {
diff --git a/backend/store/project.go b/backend/store/project.go
index 7be8bea7c7..017c4bbcd8 100644
--- a/backend/store/project.go
+++ b/backend/store/project.go
@@ -283,7 +283,7 @@ func (s *Store) listProjectImplV2(ctx context.Context, tx *Tx, find *FindProject
}
var projectMessages []*ProjectMessage
- rows, err := tx.QueryContext(ctx, `
+ rows, err := tx.QueryContext(ctx, fmt.Sprintf(`
SELECT
id,
resource_id,
@@ -294,8 +294,8 @@ func (s *Store) listProjectImplV2(ctx context.Context, tx *Tx, find *FindProject
setting,
row_status
FROM project
- WHERE `+strings.Join(where, " AND ")+`
- ORDER BY project.id`,
+ WHERE %s
+ ORDER BY project.resource_id`, strings.Join(where, " AND ")),
args...,
)
if err != nil {