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

Function resolveColumnRefsToTableSchemaDescriptor

src/validation.ts:103–123  ·  view source on GitHub ↗
(
  returnedColumns: ColumnReference[],
  tables: TableSchema[]
)

Source from the content-addressed store, hash-verified

101}
102
103function resolveColumnRefsToTableSchemaDescriptor(
104 returnedColumns: ColumnReference[],
105 tables: TableSchema[]
106): TableSchemaDescriptor {
107 let syntheticSchema: TableSchemaDescriptor = {}
108
109 for (const columnRef of returnedColumns) {
110 if (isAllOfColumnReference(columnRef)) {
111 const referencedTableSchema = assertIntactTableRef(columnRef, tables)
112
113 syntheticSchema = {
114 ...syntheticSchema,
115 ...referencedTableSchema.columnDescriptors
116 }
117 } else {
118 syntheticSchema[columnRef.columnName] = Schema.Any
119 }
120 }
121
122 return syntheticSchema
123}
124
125function validateQueryMatchesReturnType(
126 resultSchema: TableSchemaDescriptor,

Callers 2

validateQueryInvocationFunction · 0.85

Calls 2

isAllOfColumnReferenceFunction · 0.85
assertIntactTableRefFunction · 0.85

Tested by

no test coverage detected