@sqb/sqlite-dialect 5.0.7 → 6.0.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 CHANGED
@@ -6,30 +6,23 @@
6
6
 
7
7
  [![NPM Version][npm-image]][npm-url]
8
8
  [![NPM Downloads][downloads-image]][downloads-url]
9
- [![Build Status][travis-image]][travis-url]
9
+ [![CI Tests][ci-test-image]][ci-test-url]
10
10
  [![Test Coverage][coveralls-image]][coveralls-url]
11
- [![Dependencies][dependencies-image]][dependencies-url]
12
- [![DevDependencies][devdependencies-image]][devdependencies-url]
13
- [![Package Quality][quality-image]][quality-url]
14
11
 
15
12
  ## About SQB
16
13
 
17
14
  SQB is an extensible, multi-dialect SQL query builder and Database connection wrapper for NodeJS.
18
15
 
19
- ## Main goals
16
+ ## About @sqb/sqlite-dialect
20
17
 
21
- - Single code base for any sql based database
22
- - Powerful and simplified query coding scheme
23
- - Fast applications with low memory requirements
24
- - Let applications work with large data tables efficiently
25
- - Support latest JavaScript language standards
26
- - Lightweight and extensible framework.
18
+ This package registers the `sqlite` SQL serialization dialect (a `SerializerExtension` for
19
+ [`@sqb/builder`](../builder)) shared by both [`@sqb/sqlite`](../sqlite) (native `node:sqlite` /
20
+ `bun:sqlite` bindings) and [`@sqb/sqljs`](../sqljs) (the `sql.js` WASM build). It is loaded
21
+ automatically when either adapter is imported, so you normally don't need to depend on it directly.
27
22
 
28
- You can report bugs and discuss features on the [GitHub issues](https://github.com/sqbjs/sqb/issues) page
29
-
30
- Thanks to all of the great [contributions](https://github.com/sqbjs/sqb/graphs/contributors) to the project.
31
-
32
- You may want to check detailed [DOCUMENTATION](https://sqbjs.github.io/sqb/)
23
+ It applies SQLite's `LIMIT`/`OFFSET` syntax and reserved-word list. `RETURNING` is stripped from
24
+ the generated SQL; both adapters emulate it with a follow-up `SELECT` keyed on SQLite's implicit
25
+ `rowid`, rather than relying on `RETURNING` support that may not be present in every SQLite build.
33
26
 
34
27
  ## Installation
35
28
 
@@ -39,7 +32,7 @@ $ npm install @sqb/sqlite-dialect --save
39
32
 
40
33
  ## Node Compatibility
41
34
 
42
- - node >= 16.x
35
+ - node >= 20.x
43
36
 
44
37
  ### License
45
38
 
@@ -47,17 +40,9 @@ SQB is available under [MIT](LICENSE) license.
47
40
 
48
41
  [npm-image]: https://img.shields.io/npm/v/@sqb/sqlite-dialect.svg
49
42
  [npm-url]: https://npmjs.org/package/@sqb/sqlite-dialect
50
- [travis-image]: https://img.shields.io/travis/sqbjs/@sqb/sqlite-dialect/master.svg
51
- [travis-url]: https://travis-ci.org/sqbjs/@sqb/sqlite-dialect
52
- [coveralls-image]: https://img.shields.io/coveralls/sqbjs/@sqb/sqlite-dialect/master.svg
53
- [coveralls-url]: https://coveralls.io/r/sqbjs/@sqb/sqlite-dialect
54
43
  [downloads-image]: https://img.shields.io/npm/dm/@sqb/sqlite-dialect.svg
55
44
  [downloads-url]: https://npmjs.org/package/@sqb/sqlite-dialect
56
- [gitter-image]: https://badges.gitter.im/sqbjs/@sqb/sqlite-dialect.svg
57
- [gitter-url]: https://gitter.im/sqbjs/@sqb/sqlite-dialect?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
58
- [dependencies-image]: https://david-dm.org/sqbjs/@sqb/sqlite-dialect/status.svg
59
- [dependencies-url]: https://david-dm.org/sqbjs/@sqb/sqlite-dialect
60
- [devdependencies-image]: https://david-dm.org/sqbjs/@sqb/sqlite-dialect/dev-status.svg
61
- [devdependencies-url]: https://david-dm.org/sqbjs/@sqb/sqlite-dialect?type=dev
62
- [quality-image]: http://npm.packagequality.com/shield/@sqb/sqlite-dialect.png
63
- [quality-url]: http://packagequality.com/#?package=@sqb/sqlite-dialect
45
+ [ci-test-image]: https://github.com/panates/sqb/actions/workflows/test.yml/badge.svg
46
+ [ci-test-url]: https://github.com/panates/sqb/actions/workflows/test.yml
47
+ [coveralls-image]: https://coveralls.io/repos/github/sqbjs/sqb/badge.svg?branch=master
48
+ [coveralls-url]: https://coveralls.io/github/sqbjs/sqb?branch=master
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@sqb/sqlite-dialect",
3
3
  "description": "SQB serialization extension for SQLite database",
4
- "version": "5.0.7",
4
+ "version": "6.0.1",
5
5
  "author": "Panates",
6
6
  "license": "Apache-2.0",
7
7
  "dependencies": {
8
8
  "tslib": "^2.8.1"
9
9
  },
10
10
  "peerDependencies": {
11
- "@sqb/builder": "^5.0.7"
11
+ "@sqb/builder": "^6.0.1"
12
12
  },
13
13
  "type": "module",
14
14
  "module": "./index.js",
@@ -1,6 +1,8 @@
1
1
  import { type DefaultSerializeFunction, SerializationType, SerializeContext, type SerializerExtension } from '@sqb/builder';
2
2
  export declare class SqliteSerializer implements SerializerExtension {
3
3
  dialect: string;
4
+ reservedWords: Set<string>;
5
+ isReservedWord(_: any, s: any): boolean;
4
6
  serialize(ctx: SerializeContext, type: SerializationType | string, o: any, defFn: DefaultSerializeFunction): string | undefined;
5
7
  private _serializeSelect;
6
8
  private _serializeReturning;
@@ -1,6 +1,102 @@
1
1
  import { SerializationType, SerializeContext, } from '@sqb/builder';
2
+ // SQLite keywords (https://www.sqlite.org/lang_keywords.html) that are not
3
+ // already covered by SerializeContext's base reservedWords list.
4
+ const reservedWords = new Set([
5
+ 'abort',
6
+ 'action',
7
+ 'after',
8
+ 'always',
9
+ 'analyze',
10
+ 'attach',
11
+ 'autoincrement',
12
+ 'before',
13
+ 'begin',
14
+ 'collate',
15
+ 'commit',
16
+ 'conflict',
17
+ 'cross',
18
+ 'current',
19
+ 'current_date',
20
+ 'current_time',
21
+ 'current_timestamp',
22
+ 'database',
23
+ 'deferrable',
24
+ 'deferred',
25
+ 'detach',
26
+ 'do',
27
+ 'each',
28
+ 'escape',
29
+ 'exclusive',
30
+ 'exists',
31
+ 'explain',
32
+ 'fail',
33
+ 'filter',
34
+ 'first',
35
+ 'following',
36
+ 'generated',
37
+ 'glob',
38
+ 'groups',
39
+ 'if',
40
+ 'ignore',
41
+ 'immediate',
42
+ 'indexed',
43
+ 'initially',
44
+ 'instead',
45
+ 'intersect',
46
+ 'isnull',
47
+ 'last',
48
+ 'limit',
49
+ 'match',
50
+ 'materialized',
51
+ 'natural',
52
+ 'no',
53
+ 'nothing',
54
+ 'notnull',
55
+ 'nulls',
56
+ 'of',
57
+ 'offset',
58
+ 'others',
59
+ 'over',
60
+ 'partition',
61
+ 'plan',
62
+ 'pragma',
63
+ 'preceding',
64
+ 'query',
65
+ 'raise',
66
+ 'range',
67
+ 'recursive',
68
+ 'regexp',
69
+ 'reindex',
70
+ 'release',
71
+ 'rename',
72
+ 'replace',
73
+ 'restrict',
74
+ 'returning',
75
+ 'rollback',
76
+ 'row',
77
+ 'rows',
78
+ 'savepoint',
79
+ 'set',
80
+ 'temp',
81
+ 'temporary',
82
+ 'ties',
83
+ 'transaction',
84
+ 'trigger',
85
+ 'unbounded',
86
+ 'using',
87
+ 'vacuum',
88
+ 'values',
89
+ 'view',
90
+ 'virtual',
91
+ 'window',
92
+ 'without',
93
+ ]);
2
94
  export class SqliteSerializer {
3
95
  dialect = 'sqlite';
96
+ reservedWords = reservedWords;
97
+ isReservedWord(_, s) {
98
+ return s && typeof s === 'string' && reservedWords.has(s.toLowerCase());
99
+ }
4
100
  serialize(ctx, type, o, defFn) {
5
101
  switch (type) {
6
102
  case SerializationType.SELECT_QUERY: