Release Query Tools 0.2.0
Verify / verify (push) Canceled after 0s

This commit is contained in:
2026-09-02 10:28:20 +02:00
parent 2730ce08b2
commit f44d0598da
34 changed files with 5153 additions and 300 deletions
+28 -1
View File
@@ -1,6 +1,6 @@
import { describe, expect, it } from "vitest";
import { parseData } from "../../src/core/data";
import { runQuery } from "../../src/core/query";
import { parsePathQuery, parseSqlQuery, runQuery } from "../../src/core/query";
describe("query engine", () => {
const root = parseData(
'[{"team":"a","n":2},{"team":"a","n":4},{"team":"b","n":9}]',
@@ -32,4 +32,31 @@ describe("query engine", () => {
/Unsupported path/iu,
);
});
it("exposes parsed SQL and path ASTs", () => {
expect(
parseSqlQuery(
"SELECT team AS group_name WHERE n >= 2 ORDER BY n DESC LIMIT 4",
),
).toMatchObject({
type: "sql-query",
select: [{ type: "field", path: ["team"], alias: "group_name" }],
where: [{ type: "condition", path: ["n"], operator: ">=", value: 2 }],
orderBy: { path: ["n"], direction: "DESC" },
limit: 4,
});
expect(parsePathQuery("$[*][?(@.n >= 4)].team").segments).toEqual([
{ type: "wildcard" },
{
type: "filter",
condition: {
type: "condition",
path: ["n"],
operator: ">=",
value: 4,
},
},
{ type: "property", key: "team", quoted: false },
]);
});
});