( tableIdentifier: string, tableRefs: Array<QueryNodePath<QueryParser.RelationRef>> )
| 14 | } |
| 15 | |
| 16 | export function resolveTableName( |
| 17 | tableIdentifier: string, |
| 18 | tableRefs: Array<QueryNodePath<QueryParser.RelationRef>> |
| 19 | ): string { |
| 20 | const matchingTableRef = tableRefs.find(tableRef => { |
| 21 | const refNode = tableRef.node |
| 22 | return refNode.RangeVar.alias |
| 23 | ? refNode.RangeVar.alias.Alias.aliasname === tableIdentifier |
| 24 | : refNode.RangeVar.relname === tableIdentifier |
| 25 | }) |
| 26 | |
| 27 | if (matchingTableRef) { |
| 28 | return matchingTableRef.node.RangeVar.relname |
| 29 | } else { |
| 30 | throw new Error(`No matching table reference found for "${tableIdentifier}".`) |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | export function resolveColumnReference( |
| 35 | path: QueryNodePath<QueryParser.ColumnRef>, |
no outgoing calls
no test coverage detected