MCPcopy Create free account
hub / github.com/andywer/postguard / resolveTable

Function resolveTable

src/resolver.ts:87–108  ·  view source on GitHub ↗
(columnRef: ColumnReference, tables: TableSchema[])

Source from the content-addressed store, hash-verified

85}
86
87function 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
110function resolveStarColumnRef(
111 columnRef: ColumnReference,

Callers 1

resolveStarColumnRefFunction · 0.85

Calls 1

getTableByNameFunction · 0.85

Tested by

no test coverage detected