(
schemaName: string,
tableName: string,
options: SelectFromTableOptions
)
| 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( |
nothing calls this directly
no test coverage detected