@slickgrid-universal/sql 10.4.1 → 10.5.0
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/LICENSE +25 -0
- package/README.md +40 -12
- package/package.json +4 -9
- package/src/services/__tests__/sql.service.spec.ts +12 -12
package/LICENSE
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
Copyright (c) 2020-present, Ghislain B.
|
|
2
|
+
https://github.com/ghiscoding/slickgrid-universal
|
|
3
|
+
|
|
4
|
+
and the original author of SlickGrid
|
|
5
|
+
Michael Leibman, michael{dot}leibman{at}gmail{dot}com
|
|
6
|
+
http://github.com/mleibman/slickgrid
|
|
7
|
+
|
|
8
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
9
|
+
a copy of this software and associated documentation files (the
|
|
10
|
+
"Software"), to deal in the Software without restriction, including
|
|
11
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
12
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
13
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
14
|
+
the following conditions:
|
|
15
|
+
|
|
16
|
+
The above copyright notice and this permission notice shall be
|
|
17
|
+
included in all copies or substantial portions of the Software.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
20
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
21
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
22
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
23
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
24
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
25
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
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.0",
|
|
4
4
|
"description": "SlickGrid Universal SQL Backend Service (implements BackendService for SQL)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -19,12 +19,6 @@
|
|
|
19
19
|
"/dist",
|
|
20
20
|
"/src"
|
|
21
21
|
],
|
|
22
|
-
"scripts": {
|
|
23
|
-
"build": "pnpm run clean && tsc",
|
|
24
|
-
"build:incremental": "tsc --incremental --declaration",
|
|
25
|
-
"clean": "remove dist tsconfig.tsbuildinfo",
|
|
26
|
-
"dev": "pnpm build:incremental"
|
|
27
|
-
},
|
|
28
22
|
"license": "MIT",
|
|
29
23
|
"author": "Ghislain B.",
|
|
30
24
|
"homepage": "https://github.com/ghiscoding/slickgrid-universal",
|
|
@@ -37,11 +31,12 @@
|
|
|
37
31
|
"url": "https://github.com/ghiscoding/slickgrid-universal/issues"
|
|
38
32
|
},
|
|
39
33
|
"dependencies": {
|
|
40
|
-
"@slickgrid-universal/common": "10.
|
|
34
|
+
"@slickgrid-universal/common": "10.5.0",
|
|
41
35
|
"@slickgrid-universal/utils": "10.3.0"
|
|
42
36
|
},
|
|
43
37
|
"funding": {
|
|
44
38
|
"type": "ko_fi",
|
|
45
39
|
"url": "https://ko-fi.com/ghiscoding"
|
|
46
|
-
}
|
|
40
|
+
},
|
|
41
|
+
"gitHead": "2481a4ebba8d2b030e5b00dcf039cb569b3d7e8e"
|
|
47
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 }) => {
|