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

Function validateQueryInvocation

src/validation.ts:182–205  ·  view source on GitHub ↗
(invocation: QueryInvocation, tables: TableSchema[])

Source from the content-addressed store, hash-verified

180}
181
182function validateQueryInvocation(invocation: QueryInvocation, tables: TableSchema[]) {
183 if (
184 !invocation.resultTypeAssertion ||
185 invocation.query.returnedColumns.some(isUnresolvableColumnReference)
186 ) {
187 return
188 }
189
190 try {
191 const resultTypeAssertion = invocation.resultTypeAssertion
192 const resultSchema = resolveColumnRefsToTableSchemaDescriptor(
193 invocation.query.returnedColumns,
194 tables
195 )
196 validateQueryMatchesReturnType(
197 resultSchema,
198 resultTypeAssertion.schema,
199 resultTypeAssertion.path,
200 invocation.query
201 )
202 } catch (error) {
203 throw augmentFileValidationError(error, invocation.query)
204 }
205}
206
207export function validateQuery(invocation: QueryInvocation, tables: TableSchema[]) {
208 const tableExpressions: TableSchema[] = getAllSubqueries(invocation.query)

Callers 1

validateQueryFunction · 0.85

Tested by

no test coverage detected