MCPcopy Create free account
hub / github.com/outerbase/studio / selectTable

Function selectTable

src/drivers/common-sql-imp.ts:165–187  ·  view source on GitHub ↗
(
    schemaName: string,
    tableName: string,
    options: SelectFromTableOptions
  )

Source from the content-addressed store, hash-verified

163 }
164
165 async selectTable(
166 schemaName: string,
167 tableName: string,
168 options: SelectFromTableOptions
169 ): Promise<{ data: DatabaseResultSet; schema: DatabaseTableSchema }> {
170 const whereRaw = options.whereRaw?.trim();
171
172 const orderPart =
173 options.orderBy && options.orderBy.length > 0
174 ? options.orderBy
175 .map((r) => `${this.escapeId(r.columnName)} ${r.by}`)
176 .join(", ")
177 : "";
178
179 const sql = `SELECT * FROM ${this.escapeId(schemaName)}.${this.escapeId(tableName)}${
180 whereRaw ? ` WHERE ${whereRaw} ` : ""
181 } ${orderPart ? ` ORDER BY ${orderPart}` : ""} LIMIT ${escapeSqlValue(options.limit)} OFFSET ${escapeSqlValue(options.offset)};`;
182
183 return {
184 data: await this.query(sql),
185 schema: await this.tableSchema(schemaName, tableName),
186 };
187 }
188
189 async dropTable(schemaName: string, tableName: string): Promise<void> {
190 await this.query(

Callers

nothing calls this directly

Calls 4

escapeSqlValueFunction · 0.90
queryMethod · 0.65
escapeIdMethod · 0.45
tableSchemaMethod · 0.45

Tested by

no test coverage detected