(columnRef: ColumnReference, tables: TableSchema[])
| 85 | } |
| 86 | |
| 87 | function resolveTable(columnRef: ColumnReference, tables: TableSchema[]): TableSchema { |
| 88 | if ("tableName" in columnRef) { |
| 89 | return getTableByName(tables, columnRef.tableName) |
| 90 | } else { |
| 91 | if (columnRef.tableRefsInScope.length === 0) { |
| 92 | throw new Error(`Cannot resolve unqualified "*" column selector: No known tables.`) |
| 93 | } |
| 94 | if (columnRef.tableRefsInScope.length > 1) { |
| 95 | const tablesInScopeNames = columnRef.tableRefsInScope.map( |
| 96 | tableRef => `"${tableRef.tableName}"` |
| 97 | ) |
| 98 | throw new Error( |
| 99 | `Cannot resolve unqualified "*" column selector. More than one table in scope: ${tablesInScopeNames.join( |
| 100 | ", " |
| 101 | )}` |
| 102 | ) |
| 103 | } |
| 104 | |
| 105 | const tableName = columnRef.tableRefsInScope[0].tableName |
| 106 | return getTableByName(tables, tableName) |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | function resolveStarColumnRef( |
| 111 | columnRef: ColumnReference, |
no test coverage detected