(schemaName: string, name: string)
| 409 | } |
| 410 | |
| 411 | async view(schemaName: string, name: string): Promise<DatabaseViewSchema> { |
| 412 | const sql = `SELECT * FROM information_schema.views WHERE TABLE_SCHEMA=${this.escapeValue(schemaName)} AND TABLE_NAME=${this.escapeValue(name)}`; |
| 413 | const result = await this.query(sql); |
| 414 | |
| 415 | const viewRow = result.rows[0] as { view_definition: string } | undefined; |
| 416 | if (!viewRow) throw new Error("View dose not exist"); |
| 417 | |
| 418 | const statement = viewRow.view_definition.trim(); |
| 419 | |
| 420 | return { |
| 421 | schemaName, |
| 422 | name, |
| 423 | statement, |
| 424 | }; |
| 425 | } |
| 426 | |
| 427 | createView(view: DatabaseViewSchema): string { |
| 428 | return `CREATE VIEW ${this.escapeId(view.schemaName)}.${this.escapeId(view.name)} AS ${view.statement}`; |
nothing calls this directly
no test coverage detected