MCPcopy Create free account
hub / github.com/Borvik/vscode-postgres / getChildren

Method getChildren

src/tree/tableNode.ts:42–75  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

40 }
41
42 public async getChildren(): Promise<INode[]> {
43 const connection = await Database.createConnection(this.connection);
44 //config.get<boolean>("prettyPrintJSONfields") ? `.jsonb-field, .json-field { white-space: pre; }` : ``;
45 const configSort = Global.Configuration.get<string>("tableColumnSortOrder");
46 const sortOptions = {
47 "db-order": 'a.attnum',
48 "alpha": 'a.attname',
49 "reverse-alpha": 'a.attname DESC'
50 };
51 if (!sortOptions[configSort]) sortOptions[configSort] = 'a.attnum';
52
53 let tableSchema = this.schema ? this.schema : 'public';
54 let query = SqlQueryManager.getVersionQueries(connection.pg_version);
55
56 try {
57 let res: QueryResult = null;
58
59 // sorting is done via format - other fields through parameterized queries
60 res = await connection.query(query.format(query.TableColumns, sortOptions[configSort]), [
61 this.getQuotedTableName(),
62 this.connection.database,
63 tableSchema,
64 this.table
65 ])
66
67 return res.rows.map<ColumnNode>(column => {
68 return new ColumnNode(this.connection, this.table, column);
69 });
70 } catch(err) {
71 return [new InfoNode(err)];
72 } finally {
73 await connection.end();
74 }
75 }
76}

Callers

nothing calls this directly

Calls 4

getQuotedTableNameMethod · 0.95
createConnectionMethod · 0.80
getVersionQueriesMethod · 0.80
formatMethod · 0.80

Tested by

no test coverage detected