Skip to content

Commit

Permalink
Update dependencies & tests to match
Browse files Browse the repository at this point in the history
Update @balena/lf-to-abstract-sql from 5.0.0 to 5.0.2
Update @balena/odata-parser from 3.0.0 to 3.1.0
Update @balena/odata-to-abstract-sql from 6.0.1 to 6.4.0
Update @balena/sbvr-parser from 1.4.3 to 1.4.6
Update @balena/sbvr-types from 7.0.1 to 9.0.2

Change-type: patch
  • Loading branch information
thgreasi committed Oct 4, 2024
1 parent 0d128f8 commit 81f57ba
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 43 deletions.
30 changes: 15 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,27 @@
"repository": "https://github.com/balena-io-modules/abstract-sql-compiler.git",
"author": "",
"dependencies": {
"@balena/sbvr-types": "^7.0.1",
"@balena/sbvr-types": "^9.0.2, ^8.0.0, ^7.0.1",
"lodash": "^4.17.21"
},
"devDependencies": {
"@balena/lf-to-abstract-sql": "^5.0.0",
"@balena/lint": "^8.0.0",
"@balena/odata-parser": "^3.0.0",
"@balena/odata-to-abstract-sql": "^6.0.1",
"@balena/sbvr-parser": "^1.4.3",
"@balena/lf-to-abstract-sql": "^5.0.2",
"@balena/lint": "^8.2.8",
"@balena/odata-parser": "^3.1.0",
"@balena/odata-to-abstract-sql": "^6.4.0",
"@balena/sbvr-parser": "^1.4.6",
"@types/chai": "^4.3.4",
"@types/common-tags": "^1.8.1",
"@types/lodash": "^4.14.192",
"@types/mocha": "^10.0.1",
"@types/node": "^20.0.0",
"@types/common-tags": "^1.8.4",
"@types/lodash": "^4.17.10",
"@types/mocha": "^10.0.8",
"@types/node": "^22.7.4",
"chai": "^4.3.7",
"common-tags": "^1.8.2",
"husky": "^9.0.0",
"lint-staged": "^15.0.0",
"mocha": "^10.2.0",
"ts-node": "^10.9.1",
"typescript": "^5.4.3"
"husky": "^9.1.6",
"lint-staged": "^15.2.10",
"mocha": "^10.7.3",
"ts-node": "^10.9.2",
"typescript": "^5.6.2"
},
"lint-staged": {
"*.js": [
Expand Down
16 changes: 8 additions & 8 deletions test/odata/expand.js
Original file line number Diff line number Diff line change
Expand Up @@ -436,17 +436,17 @@ SELECT (
SELECT ${aliasLicenceFields.join(', ')}
FROM "licence" AS "pilot.licence"
WHERE "pilot"."licence" = "pilot.licence"."id"
LIMIT 10
LIMIT ?
) AS "pilot.licence"
) AS "licence", ${remainingPilotFields}
FROM "pilot"`,
);
});
};
const url = '/pilot?$expand=licence($top=10)';
test.postgres(url, testFunc(postgresAgg));
test.mysql.skip(url, testFunc(mysqlAgg));
test.websql.skip(url, testFunc(websqlAgg));
test.postgres(url, 'GET', [['Bind', 0]], testFunc(postgresAgg));
test.mysql.skip(url, 'GET', [['Bind', 0]], testFunc(mysqlAgg));
test.websql.skip(url, 'GET', [['Bind', 0]], testFunc(websqlAgg));
})();

(function () {
Expand Down Expand Up @@ -493,17 +493,17 @@ SELECT (
SELECT ${aliasLicenceFields.join(', ')}
FROM "licence" AS "pilot.licence"
WHERE "pilot"."licence" = "pilot.licence"."id"
OFFSET 10
OFFSET ?
) AS "pilot.licence"
) AS "licence", ${remainingPilotFields}
FROM "pilot"`,
);
});
};
const url = '/pilot?$expand=licence($skip=10)';
test.postgres(url, testFunc(postgresAgg));
test.mysql.skip(url, testFunc(mysqlAgg));
test.websql.skip(url, testFunc(websqlAgg));
test.postgres(url, 'GET', [['Bind', 0]], testFunc(postgresAgg));
test.mysql.skip(url, 'GET', [['Bind', 0]], testFunc(mysqlAgg));
test.websql.skip(url, 'GET', [['Bind', 0]], testFunc(websqlAgg));
})();

(function () {
Expand Down
12 changes: 6 additions & 6 deletions test/odata/filterby.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ let parseOperandFactory = function (defaultResource) {
typeof operand === 'boolean' ||
typeof operand === 'number' ||
_.isDate(operand) ||
(typeof operand === 'string' && operand.charAt(0) === "'")
(typeof operand === 'string' && operand.startsWith("'"))
) {
return [['Bind', bindNo++]];
}
Expand All @@ -95,7 +95,7 @@ let parseOperandFactory = function (defaultResource) {
if (operand === 'null') {
return 'NULL';
}
if (operand.charAt(0) === "'") {
if (operand.startsWith("'")) {
return '?';
}
const fieldParts = operand.split('/');
Expand Down Expand Up @@ -636,7 +636,7 @@ WHERE EXISTS (
};
const updateWhere = `\
WHERE "pilot"."id" IN ((
SELECT "pilot"."id"
SELECT "pilot"."id" AS "$modifyid"
FROM "pilot",
"pilot-can fly-plane" AS "pilot.pilot-can fly-plane",
"plane" AS "pilot.pilot-can fly-plane.plane"
Expand Down Expand Up @@ -731,7 +731,7 @@ ${updateWhere}`,
`\
DELETE FROM "pilot"
WHERE "pilot"."id" IN ((
SELECT "pilot"."id"
SELECT "pilot"."id" AS "$modifyid"
FROM "pilot",
"pilot-can fly-plane" AS "pilot.pilot-can fly-plane",
"plane" AS "pilot.pilot-can fly-plane.plane"
Expand Down Expand Up @@ -808,7 +808,7 @@ UPDATE "pilot"
SET "name" = ?
WHERE ("pilot"."id") IS NOT NULL AND ("pilot"."id") = (?)
AND "pilot"."id" IN ((
SELECT "pilot"."id"
SELECT "pilot"."id" AS "$modifyid"
FROM "pilot"
WHERE ${sql}
))`,
Expand Down Expand Up @@ -865,7 +865,7 @@ SET "created at" = DEFAULT,
"was trained by-pilot" = DEFAULT
WHERE ("pilot"."id") IS NOT NULL AND ("pilot"."id") = (?)
AND "pilot"."id" IN ((
SELECT "pilot"."id"
SELECT "pilot"."id" AS "$modifyid"
FROM "pilot"
WHERE ${sql}
))`,
Expand Down
36 changes: 22 additions & 14 deletions test/odata/paging.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,47 @@ import test from './test';
import { pilotFields } from './fields';
const pilotFieldsStr = pilotFields.join(', ');

test('/pilot?$top=5', (result, sqlEquals) => {
test('/pilot?$top=5', 'GET', [['Bind', 0]], (result, sqlEquals) => {
it('should select from pilot limited by 5', () => {
sqlEquals(
result.query,
`\
SELECT ${pilotFieldsStr}
FROM "pilot"
LIMIT 5`,
LIMIT ?`,
);
});
});

test('/pilot?$skip=100', (result, sqlEquals) => {
test('/pilot?$skip=100', 'GET', [['Bind', 0]], (result, sqlEquals) => {
it('should select from pilot offset by 100', () => {
sqlEquals(
result.query,
`\
SELECT ${pilotFieldsStr}
FROM "pilot"
OFFSET 100`,
OFFSET ?`,
);
});
});

test('/pilot?$top=5&$skip=100', (result, sqlEquals) => {
it('should select from pilot limited by 5 and offset by 100', () => {
sqlEquals(
result.query,
`\
test(
'/pilot?$top=5&$skip=100',
'GET',
[
['Bind', 0],
['Bind', 1],
],
(result, sqlEquals) => {
it('should select from pilot limited by 5 and offset by 100', () => {
sqlEquals(
result.query,
`\
SELECT ${pilotFieldsStr}
FROM "pilot"
LIMIT 5
OFFSET 100`,
);
});
});
LIMIT ?
OFFSET ?`,
);
});
},
);

0 comments on commit 81f57ba

Please sign in to comment.