From 59880417ec57d5b985b5cb2108e872a73a838402 Mon Sep 17 00:00:00 2001 From: Bobby Iliev Date: Wed, 8 Nov 2023 13:09:02 +0200 Subject: [PATCH] 136 Sort explorer objects by name --- src/providers/schema.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/providers/schema.ts b/src/providers/schema.ts index 085fa08..5d0495f 100644 --- a/src/providers/schema.ts +++ b/src/providers/schema.ts @@ -163,7 +163,7 @@ export default class DatabaseTreeProvider implements vscode.TreeDataProvider> { const sources: Promise> = new Promise((res, rej) => { - this.query("SELECT id, name, owner_id FROM mz_sources WHERE schema_id = $1", [schema]).then((results) => { + this.query("SELECT id, name, owner_id FROM mz_sources WHERE schema_id = $1 ORDER BY name", [schema]).then((results) => { let sources = results.map(({ id, name, owner_id: ownerId }) => { return new View(name, vscode.TreeItemCollapsibleState.Collapsed, { id, name, ownerId }); }); @@ -176,7 +176,7 @@ export default class DatabaseTreeProvider implements vscode.TreeDataProvider> { const sinks: Promise> = new Promise((res, rej) => { - this.query("SELECT id, name, owner_id FROM mz_sinks WHERE schema_id = $1", [schema]).then((results) => { + this.query("SELECT id, name, owner_id FROM mz_sinks WHERE schema_id = $1 ORDER BY name", [schema]).then((results) => { let sinks = results.map(({ id, name, owner_id: ownerId }) => { return new View(name, vscode.TreeItemCollapsibleState.Collapsed, { id, name, ownerId }); }); @@ -189,7 +189,7 @@ export default class DatabaseTreeProvider implements vscode.TreeDataProvider> { const views: Promise> = new Promise((res, rej) => { - this.query("SELECT id, name, owner_id FROM mz_views WHERE schema_id = $1", [schema]).then((results) => { + this.query("SELECT id, name, owner_id FROM mz_views WHERE schema_id = $1 ORDER BY name", [schema]).then((results) => { let views = results.map(({ id, name, owner_id: ownerId }) => { return new View(name, vscode.TreeItemCollapsibleState.Collapsed, { id, name, ownerId }); }); @@ -202,7 +202,7 @@ export default class DatabaseTreeProvider implements vscode.TreeDataProvider> { const materializedViews: Promise> = new Promise((res, rej) => { - this.query("SELECT id, name, owner_id, cluster_id FROM mz_materialized_views WHERE schema_id = $1", [schema]).then((results) => { + this.query("SELECT id, name, owner_id, cluster_id FROM mz_materialized_views WHERE schema_id = $1 ORDER BY name", [schema]).then((results) => { let materializedViews = results.map(({ id, name, owner_id: ownerId }) => { return new MaterializedView(name, vscode.TreeItemCollapsibleState.Collapsed, { id, name, ownerId }); }); @@ -215,7 +215,7 @@ export default class DatabaseTreeProvider implements vscode.TreeDataProvider> { const tables: Promise> = new Promise((res, rej) => { - this.query("SELECT id, name, owner_id FROM mz_tables WHERE schema_id = $1", [schema]).then((results) => { + this.query("SELECT id, name, owner_id FROM mz_tables WHERE schema_id = $1 ORDER BY name", [schema]).then((results) => { let tables = results.map(({ id, name, owner_id: ownerId }) => { return new Table(name, vscode.TreeItemCollapsibleState.Collapsed, { id, name, ownerId }); }); @@ -228,7 +228,7 @@ export default class DatabaseTreeProvider implements vscode.TreeDataProvider> { return new Promise((res, rej) => { - this.query("SELECT id, name, database_id, owner_id FROM mz_schemas WHERE database_id = $1", [database]).then((results) => { + this.query("SELECT id, name, database_id, owner_id FROM mz_schemas WHERE database_id = $1 ORDER BY name", [database]).then((results) => { const schemas = results.map(({ id, name, owner_id: ownerId }) => { return new Schema(name, vscode.TreeItemCollapsibleState.Collapsed, { id, name, ownerId }); }); @@ -239,7 +239,7 @@ export default class DatabaseTreeProvider implements vscode.TreeDataProvider> { return new Promise((res, rej) => { - this.query("SELECT name, type FROM mz_columns WHERE id = $1", [id]).then((results) => { + this.query("SELECT name, type FROM mz_columns WHERE id = $1 ORDER BY name", [id]).then((results) => { const columns = results.map(({ name, type }) => { return new Column(name, vscode.TreeItemCollapsibleState.None, { id: name, type }); });