Skip to content

Commit 8f40283

Browse files
Remove test/index.js and replace lodash with pure JavaScript
- Remove test/index.js (functionality covered by separate test files) - Replace complex omit function with simpler removeLocationProperties - Remove lodash and esbuild from devDependencies (unused) - All 32 tests passing, functionality preserved Co-Authored-By: Dan Lynch <[email protected]>
1 parent 389e2e7 commit 8f40283

File tree

3 files changed

+24
-232
lines changed

3 files changed

+24
-232
lines changed

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@
4646
"@launchql/proto-cli": "1.25.0",
4747
"@yamlize/cli": "^0.8.0",
4848
"chai": "^3.5.0",
49-
"esbuild": "^0.25.5",
50-
"lodash": "^4.17.15",
5149
"mocha": "^5.2.0",
5250
"rimraf": "5.0.0"
5351
},

test/index.js

Lines changed: 0 additions & 219 deletions
This file was deleted.

test/parsing.test.js

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,26 @@
11
const query = require("../");
22
const { expect } = require("chai");
3-
const { omit } = require("lodash");
3+
4+
function removeLocationProperties(obj) {
5+
if (typeof obj !== 'object' || obj === null) {
6+
return obj;
7+
}
8+
9+
if (Array.isArray(obj)) {
10+
return obj.map(item => removeLocationProperties(item));
11+
}
12+
13+
const result = {};
14+
for (const key in obj) {
15+
if (obj.hasOwnProperty(key)) {
16+
if (key === 'location' || key === 'stmt_len' || key === 'stmt_location') {
17+
continue; // Skip location-related properties
18+
}
19+
result[key] = removeLocationProperties(obj[key]);
20+
}
21+
}
22+
return result;
23+
}
424

525
describe("Query Parsing", () => {
626
before(async () => {
@@ -27,16 +47,9 @@ describe("Query Parsing", () => {
2747

2848
it("should support parsing multiple queries", () => {
2949
const res = query.parseQuerySync("select 1; select null;");
30-
const changedProps = [
31-
"stmt_len",
32-
"stmt_location",
33-
"stmt.SelectStmt.targetList[0].ResTarget.location",
34-
"stmt.SelectStmt.targetList[0].ResTarget.val.A_Const.location",
35-
];
36-
const removeChangedProps = (stmt) => omit(stmt, changedProps);
37-
expect(res.stmts.map(removeChangedProps)).to.deep.eq([
38-
...query.parseQuerySync("select 1;").stmts.map(removeChangedProps),
39-
...query.parseQuerySync("select null;").stmts.map(removeChangedProps),
50+
expect(res.stmts.map(removeLocationProperties)).to.deep.eq([
51+
...query.parseQuerySync("select 1;").stmts.map(removeLocationProperties),
52+
...query.parseQuerySync("select null;").stmts.map(removeLocationProperties),
4053
]);
4154
});
4255

0 commit comments

Comments
 (0)