MCPcopy
hub / github.com/liyupi/sql-mother / checkResult

Function checkResult

src/core/result.ts:26–46  ·  view source on GitHub ↗
(
  result: QueryExecResult[],
  answerResult: QueryExecResult[]
)

Source from the content-addressed store, hash-verified

24 * @param answerResult 答案结果
25 */
26export const checkResult = (
27 result: QueryExecResult[],
28 answerResult: QueryExecResult[]
29) => {
30 if (!result?.[0] || !answerResult?.[0]) {
31 return RESULT_STATUS_ENUM.ERROR;
32 }
33 // 列名需要一致
34 const resultColumns = result[0].columns;
35 const answerResultColumns = answerResult[0].columns;
36 if (JSON.stringify(resultColumns) !== JSON.stringify(answerResultColumns)) {
37 return RESULT_STATUS_ENUM.ERROR;
38 }
39 // 数据需要一致
40 const resultValues = result[0].values;
41 const answerResultValues = answerResult[0].values;
42 if (JSON.stringify(resultValues) === JSON.stringify(answerResultValues)) {
43 return RESULT_STATUS_ENUM.SUCCEED;
44 }
45 return RESULT_STATUS_ENUM.ERROR;
46};

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected