(
id: string,
name: string,
tableSchema: string,
parent_id?: string
)
| 347 | } |
| 348 | |
| 349 | public async createTableViaSchema( |
| 350 | id: string, |
| 351 | name: string, |
| 352 | tableSchema: string, |
| 353 | parent_id?: string |
| 354 | ) { |
| 355 | // FIXME: should use db transaction to execute multiple sql |
| 356 | |
| 357 | try { |
| 358 | await this.db.prepare("BEGIN TRANSACTION;").run() |
| 359 | await this.tree.addNode({ id, name, type: TreeNodeType.Table, parent_id }) |
| 360 | await this.db.exec(tableSchema) |
| 361 | // create view for table |
| 362 | await this.view.createDefaultView(getRawTableNameById(id)) |
| 363 | await this.db.prepare("COMMIT;").run() |
| 364 | } catch (error) { |
| 365 | await this.db.prepare("ROLLBACK;").run() |
| 366 | throw error |
| 367 | } |
| 368 | } |
| 369 | |
| 370 | public async fixTable(tableId: string) { |
| 371 | const tableManager = this._table(tableId) |
no test coverage detected