Skip to content

Commit 2932bc9

Browse files
committed
Defining the WHERE clause as a limiting keyword in EC24
1 parent 1319a95 commit 2932bc9

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111

12+
- [#30](https://github.com/green-code-initiative/ecoCode-javascript/issues/30) EC24: define the WHERE clause as a limiting keyword
1213
- [ecoCode#185](https://github.com/green-code-initiative/ecoCode/issues/185) Add build number to manifest
1314

1415
### Fixed

eslint-plugin/lib/rules/limit-db-query-results.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,13 @@ module.exports = {
3535
},
3636
create(context) {
3737
//list of limiting clauses to check against
38-
const limitingClauses = ["LIMIT", "TOP", "ROW_NUMBER", "FETCH FIRST"];
38+
const limitingClauses = [
39+
"LIMIT",
40+
"TOP",
41+
"ROW_NUMBER",
42+
"FETCH FIRST",
43+
"WHERE",
44+
];
3945
return {
4046
Literal: function (node) {
4147
if (typeof node.value == "string") {

eslint-plugin/tests/lib/rules/limit-db-query-results.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,14 @@ const expectedError = {
4242
ruleTester.run("limit-db-query-results", rule, {
4343
valid: [
4444
`
45-
const query = "SELECT * FROM customers LIMIT 10;";
45+
const query = "SELECT id, name, email FROM customers LIMIT 10;";
4646
`,
4747
`
4848
const query = "SELECT TOP 5 * FROM products;";
4949
`,
50+
`
51+
const query = "SELECT id, name, email FROM customers WHERE id = 1;";
52+
`,
5053
`
5154
const query = "SELECT * FROM orders FETCH FIRST 20 ROWS ONLY;";
5255
`,

0 commit comments

Comments
 (0)