(
schemaName: string,
tableName: string
)
| 232 | } |
| 233 | |
| 234 | async tableSchema( |
| 235 | schemaName: string, |
| 236 | tableName: string |
| 237 | ): Promise<DatabaseTableSchema> { |
| 238 | const sql = `SELECT * FROM ${this.escapeId(schemaName)}.sqlite_schema WHERE tbl_name = ${escapeSqlValue( |
| 239 | tableName |
| 240 | )};`; |
| 241 | const result = await this.query(sql); |
| 242 | |
| 243 | try { |
| 244 | try { |
| 245 | const rows = result.rows as Array<{ type: string; sql: string }>; |
| 246 | const def = rows.find((row) => row.type === "table"); |
| 247 | |
| 248 | if (def) { |
| 249 | const createScript = def.sql; |
| 250 | |
| 251 | return { |
| 252 | ...parseCreateTableScript(schemaName, createScript), |
| 253 | createScript, |
| 254 | schemaName, |
| 255 | type: "table", |
| 256 | }; |
| 257 | } |
| 258 | |
| 259 | throw new Error("Unexpected error finding table " + tableName); |
| 260 | } catch (e) { |
| 261 | throw new Error("Unexpected error while parsing"); |
| 262 | } |
| 263 | } catch { |
| 264 | return await this.legacyTableSchema(schemaName, tableName); |
| 265 | } |
| 266 | } |
| 267 | |
| 268 | createUpdateTableSchema(change: DatabaseTableSchemaChange): string[] { |
| 269 | return generateSqlSchemaChange(change); |
no test coverage detected