@slickgrid-universal/sql 10.4.2 → 10.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -12
- package/package.json +3 -3
- package/src/services/__tests__/sql.service.spec.ts +12 -12
package/README.md
CHANGED
|
@@ -1,17 +1,45 @@
|
|
|
1
|
-
|
|
1
|
+
[](https://opensource.org/licenses/MIT)
|
|
2
|
+
[](http://www.typescriptlang.org/)
|
|
3
|
+
[](https://www.npmjs.com/package/@slickgrid-universal/sql)
|
|
4
|
+
[](https://www.npmjs.com/package/@slickgrid-universal/sql)
|
|
2
5
|
|
|
3
|
-
|
|
6
|
+
## SQL Service
|
|
7
|
+
#### @slickgrid-universal/sql
|
|
4
8
|
|
|
5
|
-
|
|
9
|
+
SQL Service to sync a grid with native SQL queries, the service will consider any Filter/Sort and automatically build the necessary cross-platform SQL query string that is sent to your backend server.
|
|
6
10
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
11
|
+
### External Dependencies
|
|
12
|
+
No external dependency
|
|
13
|
+
|
|
14
|
+
### Installation
|
|
15
|
+
Follow the instruction provided in the main [README](https://github.com/ghiscoding/slickgrid-universal#installation), you can see a demo by looking at the [GitHub Demo](https://ghiscoding.github.io/slickgrid-universal/#/example10) page.
|
|
10
16
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
- Generates SQL queries for SlickGrid
|
|
14
|
-
- Supports filtering, sorting, and pagination
|
|
17
|
+
### Usage
|
|
18
|
+
Simply use pass the Service into the `backendServiceApi` Grid Option.
|
|
15
19
|
|
|
16
|
-
|
|
17
|
-
|
|
20
|
+
##### ViewModel
|
|
21
|
+
```ts
|
|
22
|
+
import { SqlService, type SqlServiceApi } from '@slickgrid-universal/sql';
|
|
23
|
+
|
|
24
|
+
export class MyExample {
|
|
25
|
+
initializeGrid {
|
|
26
|
+
this.gridOptions = {
|
|
27
|
+
backendServiceApi: {
|
|
28
|
+
service: new SqlService(),
|
|
29
|
+
options: {
|
|
30
|
+
tableName: 'users',
|
|
31
|
+
// datasetName: 'public', // optional, for schema/database
|
|
32
|
+
// totalCountField: 'total_count' // optional, custom field name for total count column (default: 'totalCount')
|
|
33
|
+
// identifierEscapeStyle: 'backtick', // optional style (backtick, doubleQuote, bracket)
|
|
34
|
+
},
|
|
35
|
+
preProcess: () => this.displaySpinner(true),
|
|
36
|
+
process: (query) => this.getCustomerApiCall(query),
|
|
37
|
+
postProcess: (response) => {
|
|
38
|
+
this.displaySpinner(false);
|
|
39
|
+
this.getCustomerCallback(response);
|
|
40
|
+
}
|
|
41
|
+
} satisfies SqlServiceApi<MyRowType>
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slickgrid-universal/sql",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.5.1",
|
|
4
4
|
"description": "SlickGrid Universal SQL Backend Service (implements BackendService for SQL)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -31,12 +31,12 @@
|
|
|
31
31
|
"url": "https://github.com/ghiscoding/slickgrid-universal/issues"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@slickgrid-universal/common": "10.
|
|
34
|
+
"@slickgrid-universal/common": "10.5.1",
|
|
35
35
|
"@slickgrid-universal/utils": "10.3.0"
|
|
36
36
|
},
|
|
37
37
|
"funding": {
|
|
38
38
|
"type": "ko_fi",
|
|
39
39
|
"url": "https://ko-fi.com/ghiscoding"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "fc8bb83ace994f1d2d9ee0708fc587ecab772c18"
|
|
42
42
|
}
|
|
@@ -1343,18 +1343,18 @@ describe('SqlService', () => {
|
|
|
1343
1343
|
describe('Verbatim ColumnFilters', () => {
|
|
1344
1344
|
describe.each`
|
|
1345
1345
|
description | verbatim | operator | searchTerms | expectation
|
|
1346
|
-
${'Verbatim false, Filter for null'} | ${false} | ${'EQ'} | ${null} | ${'SELECT *, COUNT(*) OVER() AS "totalCount" FROM
|
|
1347
|
-
${'Verbatim true, Filter for null'} | ${true} | ${'EQ'} | ${null} | ${'SELECT *, COUNT(*) OVER() AS "totalCount" FROM
|
|
1348
|
-
${'Verbatim false, Empty string'} | ${false} | ${'EQ'} | ${''} | ${'SELECT *, COUNT(*) OVER() AS "totalCount" FROM
|
|
1349
|
-
${'Verbatim true, Empty string'} | ${true} | ${'EQ'} | ${''} | ${'SELECT *, COUNT(*) OVER() AS "totalCount" FROM
|
|
1350
|
-
${'Verbatim false, Empty list'} | ${false} | ${'IN'} | ${[]} | ${'SELECT *, COUNT(*) OVER() AS "totalCount" FROM
|
|
1351
|
-
${'Verbatim true, Empty list'} | ${true} | ${'IN'} | ${[]} | ${'SELECT *, COUNT(*) OVER() AS "totalCount" FROM
|
|
1352
|
-
${'Verbatim false, Filter for null (in list)'} | ${false} | ${'IN'} | ${[null]} | ${'SELECT *, COUNT(*) OVER() AS "totalCount" FROM
|
|
1353
|
-
${'Verbatim true, Filter for null (in list)'} | ${true} | ${'IN'} | ${[null]} | ${'SELECT *, COUNT(*) OVER() AS "totalCount" FROM
|
|
1354
|
-
${'Verbatim false, Filter for empty string (in list)'} | ${false} | ${'IN'} | ${['']} | ${'SELECT *, COUNT(*) OVER() AS "totalCount" FROM
|
|
1355
|
-
${'Verbatim true, Filter for empty string (in list)'} | ${true} | ${'IN'} | ${['']} | ${'SELECT *, COUNT(*) OVER() AS "totalCount" FROM
|
|
1356
|
-
${'Verbatim false, Filter for female'} | ${false} | ${'IN'} | ${['female']} | ${'SELECT *, COUNT(*) OVER() AS "totalCount" FROM
|
|
1357
|
-
${'Verbatim true, Filter for female'} | ${true} | ${'IN'} | ${['female']} | ${'SELECT *, COUNT(*) OVER() AS "totalCount" FROM
|
|
1346
|
+
${'Verbatim false, Filter for null'} | ${false} | ${'EQ'} | ${null} | ${'SELECT *, COUNT(*) OVER() AS "totalCount" FROM "users" LIMIT 10 OFFSET 0'}
|
|
1347
|
+
${'Verbatim true, Filter for null'} | ${true} | ${'EQ'} | ${null} | ${'SELECT *, COUNT(*) OVER() AS "totalCount" FROM "users" WHERE "gender" IS NULL LIMIT 10 OFFSET 0'}
|
|
1348
|
+
${'Verbatim false, Empty string'} | ${false} | ${'EQ'} | ${''} | ${'SELECT *, COUNT(*) OVER() AS "totalCount" FROM "users" LIMIT 10 OFFSET 0'}
|
|
1349
|
+
${'Verbatim true, Empty string'} | ${true} | ${'EQ'} | ${''} | ${'SELECT *, COUNT(*) OVER() AS "totalCount" FROM "users" WHERE "gender" = \'\' LIMIT 10 OFFSET 0'}
|
|
1350
|
+
${'Verbatim false, Empty list'} | ${false} | ${'IN'} | ${[]} | ${'SELECT *, COUNT(*) OVER() AS "totalCount" FROM "users" LIMIT 10 OFFSET 0'}
|
|
1351
|
+
${'Verbatim true, Empty list'} | ${true} | ${'IN'} | ${[]} | ${'SELECT *, COUNT(*) OVER() AS "totalCount" FROM "users" LIMIT 10 OFFSET 0'}
|
|
1352
|
+
${'Verbatim false, Filter for null (in list)'} | ${false} | ${'IN'} | ${[null]} | ${'SELECT *, COUNT(*) OVER() AS "totalCount" FROM "users" WHERE "gender" IN (\'\') LIMIT 10 OFFSET 0'}
|
|
1353
|
+
${'Verbatim true, Filter for null (in list)'} | ${true} | ${'IN'} | ${[null]} | ${'SELECT *, COUNT(*) OVER() AS "totalCount" FROM "users" WHERE "gender" IS NULL LIMIT 10 OFFSET 0'}
|
|
1354
|
+
${'Verbatim false, Filter for empty string (in list)'} | ${false} | ${'IN'} | ${['']} | ${'SELECT *, COUNT(*) OVER() AS "totalCount" FROM "users" WHERE "gender" IN (\'\') LIMIT 10 OFFSET 0'}
|
|
1355
|
+
${'Verbatim true, Filter for empty string (in list)'} | ${true} | ${'IN'} | ${['']} | ${'SELECT *, COUNT(*) OVER() AS "totalCount" FROM "users" WHERE "gender" = \'\' LIMIT 10 OFFSET 0'}
|
|
1356
|
+
${'Verbatim false, Filter for female'} | ${false} | ${'IN'} | ${['female']} | ${'SELECT *, COUNT(*) OVER() AS "totalCount" FROM "users" WHERE "gender" IN (\'female\') LIMIT 10 OFFSET 0'}
|
|
1357
|
+
${'Verbatim true, Filter for female'} | ${true} | ${'IN'} | ${['female']} | ${'SELECT *, COUNT(*) OVER() AS "totalCount" FROM "users" WHERE "gender" = \'female\' LIMIT 10 OFFSET 0'}
|
|
1358
1358
|
${'Verbatim false, Filter for female/male'} | ${false} | ${'IN'} | ${['female', 'male']} | ${'SELECT *, COUNT(*) OVER() AS "totalCount" FROM "users" WHERE "gender" IN (\'female\',\'male\') LIMIT 10 OFFSET 0'}
|
|
1359
1359
|
${'Verbatim true, Filter for female/male'} | ${true} | ${'IN'} | ${['female', 'male']} | ${'SELECT *, COUNT(*) OVER() AS "totalCount" FROM "users" WHERE "gender" IN (\'female\',\'male\') LIMIT 10 OFFSET 0'}
|
|
1360
1360
|
`(`$description`, ({ verbatim, operator, searchTerms, expectation }) => {
|