@sqb/oracle-dialect 4.11.2 → 4.12.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/README.md CHANGED
@@ -18,12 +18,12 @@ SQB is an extensible, multi-dialect SQL query builder and Database connection wr
18
18
 
19
19
  ## Main goals
20
20
 
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.
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.
27
27
 
28
28
  You can report bugs and discuss features on the [GitHub issues](https://github.com/sqbjs/sqb/issues) page
29
29
 
@@ -39,40 +39,25 @@ $ npm install @sqb/oracle-dialect --save
39
39
 
40
40
  ## Node Compatibility
41
41
 
42
- - node >= 16.x
42
+ - node >= 16.x
43
43
 
44
44
  ### License
45
45
 
46
46
  SQB is available under [MIT](LICENSE) license.
47
47
 
48
48
  [npm-image]: https://img.shields.io/npm/v/@sqb/oracle-dialect.svg
49
-
50
49
  [npm-url]: https://npmjs.org/package/@sqb/oracle-dialect
51
-
52
50
  [travis-image]: https://img.shields.io/travis/sqbjs/@sqb/oracle-dialect/master.svg
53
-
54
51
  [travis-url]: https://travis-ci.org/sqbjs/@sqb/oracle-dialect
55
-
56
52
  [coveralls-image]: https://img.shields.io/coveralls/sqbjs/@sqb/oracle-dialect/master.svg
57
-
58
53
  [coveralls-url]: https://coveralls.io/r/sqbjs/@sqb/oracle-dialect
59
-
60
54
  [downloads-image]: https://img.shields.io/npm/dm/@sqb/oracle-dialect.svg
61
-
62
55
  [downloads-url]: https://npmjs.org/package/@sqb/oracle-dialect
63
-
64
56
  [gitter-image]: https://badges.gitter.im/sqbjs/@sqb/oracle-dialect.svg
65
-
66
57
  [gitter-url]: https://gitter.im/sqbjs/@sqb/oracle-dialect?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
67
-
68
58
  [dependencies-image]: https://david-dm.org/sqbjs/@sqb/oracle-dialect/status.svg
69
-
70
- [dependencies-url]:https://david-dm.org/sqbjs/@sqb/oracle-dialect
71
-
59
+ [dependencies-url]: https://david-dm.org/sqbjs/@sqb/oracle-dialect
72
60
  [devdependencies-image]: https://david-dm.org/sqbjs/@sqb/oracle-dialect/dev-status.svg
73
-
74
- [devdependencies-url]:https://david-dm.org/sqbjs/@sqb/oracle-dialect?type=dev
75
-
61
+ [devdependencies-url]: https://david-dm.org/sqbjs/@sqb/oracle-dialect?type=dev
76
62
  [quality-image]: http://npm.packagequality.com/shield/@sqb/oracle-dialect.png
77
-
78
63
  [quality-url]: http://packagequality.com/#?package=@sqb/oracle-dialect
@@ -8,8 +8,7 @@ class OracleSerializer {
8
8
  this.dialect = 'oracle';
9
9
  }
10
10
  isReservedWord(ctx, s) {
11
- return s && typeof s === 'string' &&
12
- reservedWords.includes(s.toLowerCase());
11
+ return s && typeof s === 'string' && reservedWords.includes(s.toLowerCase());
13
12
  }
14
13
  serialize(ctx, type, o, defFn) {
15
14
  switch (type) {
@@ -36,30 +35,31 @@ class OracleSerializer {
36
35
  _serializeSelect(ctx, o, defFn) {
37
36
  let out = defFn(ctx, o);
38
37
  const limit = o.limit || 0;
39
- const offset = Math.max((o.offset || 0), 0);
38
+ const offset = Math.max(o.offset || 0, 0);
40
39
  if (limit || offset) {
41
40
  if (ctx.dialectVersion && ctx.dialectVersion >= '12') {
42
41
  if (offset)
43
- out += '\nOFFSET ' + offset + ' ROWS' +
44
- (limit ? ' FETCH NEXT ' + limit + ' ROWS ONLY' : '');
42
+ out += '\nOFFSET ' + offset + ' ROWS' + (limit ? ' FETCH NEXT ' + limit + ' ROWS ONLY' : '');
45
43
  else
46
44
  out += '\nFETCH FIRST ' + limit + ' ROWS ONLY';
47
45
  }
48
46
  else {
49
47
  if (offset || o.orderBy) {
50
- out = 'select * from (\n\t' +
51
- 'select /*+ first_rows(' + (limit || 100) +
52
- ') */ t.*, rownum row$number from (\n\t' +
53
- out + '\n\b' +
54
- ') t' +
55
- (limit ? ' where rownum <= ' + (limit + offset) : '') + '\n\b)';
48
+ out =
49
+ 'select * from (\n\t' +
50
+ 'select /*+ first_rows(' +
51
+ (limit || 100) +
52
+ ') */ t.*, rownum row$number from (\n\t' +
53
+ out +
54
+ '\n\b' +
55
+ ') t' +
56
+ (limit ? ' where rownum <= ' + (limit + offset) : '') +
57
+ '\n\b)';
56
58
  if (offset)
57
59
  out += ' where row$number >= ' + (offset + 1);
58
60
  }
59
61
  else {
60
- out = 'select * from (\n\t' +
61
- out + '\n\b' +
62
- ') where rownum <= ' + limit;
62
+ out = 'select * from (\n\t' + out + '\n\b' + ') where rownum <= ' + limit;
63
63
  }
64
64
  }
65
65
  }
@@ -85,8 +85,7 @@ class OracleSerializer {
85
85
  return defFn(ctx, { ...o, operatorType: builder_1.OperatorType.isNot, symbol: 'not in' });
86
86
  }
87
87
  else if ((o.right?.expression && o.right?.expression === 'null') ||
88
- (o.right && o.right?.value == null &&
89
- (!o.right.expression || o.right.expression.startsWith(':')))) {
88
+ (o.right && o.right?.value == null && (!o.right.expression || o.right.expression.startsWith(':')))) {
90
89
  if (o.right.expression?.startsWith(':')) {
91
90
  const s = o.right.expression.substring(1);
92
91
  if (ctx.params)
@@ -108,7 +107,7 @@ class OracleSerializer {
108
107
  _serializeStringValue(ctx, o, defFn) {
109
108
  if (typeof o === 'string') {
110
109
  if (o.match(/^\d{4}-\d{2}-\d{2}$/))
111
- return 'to_date(' + o + ', \'yyyy-mm-dd\')';
110
+ return 'to_date(' + o + ", 'yyyy-mm-dd')";
112
111
  if (o.match(/^\d{4}-\d{2}-\d{2}T/))
113
112
  return `to_timestamp_tz('${o}','yyyy-mm-dd"T"hh24:mi:sstzh:tzm')`;
114
113
  }
@@ -116,29 +115,29 @@ class OracleSerializer {
116
115
  }
117
116
  _serializeDateValue(ctx, o, defFn) {
118
117
  const s = defFn(ctx, o);
119
- return s && (s.length <= 12 ?
120
- 'to_date(' + s + ', \'yyyy-mm-dd\')' :
121
- 'to_date(' + s + ', \'yyyy-mm-dd hh24:mi:ss\')');
118
+ return s && (s.length <= 12 ? 'to_date(' + s + ", 'yyyy-mm-dd')" : 'to_date(' + s + ", 'yyyy-mm-dd hh24:mi:ss')");
122
119
  }
123
120
  _serializeBooleanValue(_ctx, o) {
124
- return o == null ? 'null' : (o ? '1' : '0');
121
+ return o == null ? 'null' : o ? '1' : '0';
125
122
  }
126
123
  // noinspection JSUnusedLocalSymbols
127
124
  _serializeStringAGG(ctx, o,
128
125
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
129
126
  defFn) {
130
- return 'listagg(' + o.field +
131
- ',\'' + o.delimiter + '\') within group (' +
132
- (o.orderBy ? o.orderBy : 'order by null') + ')' +
133
- (o.alias ? ' ' + o.alias : '');
127
+ return ('listagg(' +
128
+ o.field +
129
+ ",'" +
130
+ o.delimiter +
131
+ "') within group (" +
132
+ (o.orderBy ? o.orderBy : 'order by null') +
133
+ ')' +
134
+ (o.alias ? ' ' + o.alias : ''));
134
135
  }
135
136
  // noinspection JSUnusedLocalSymbols
136
137
  _serializeSequenceGetter(ctx, o,
137
138
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
138
139
  defFn) {
139
- return o.genName + '.' +
140
- (o.next ? 'nextval' : 'currval') +
141
- (o.alias ? ' ' + o.alias : '');
140
+ return o.genName + '.' + (o.next ? 'nextval' : 'currval') + (o.alias ? ' ' + o.alias : '');
142
141
  }
143
142
  _serializeReturning() {
144
143
  return '';
@@ -1,12 +1,11 @@
1
- import { OperatorType, SerializationType } from '@sqb/builder';
1
+ import { OperatorType, SerializationType, } from '@sqb/builder';
2
2
  const reservedWords = ['comment', 'dual'];
3
3
  export class OracleSerializer {
4
4
  constructor() {
5
5
  this.dialect = 'oracle';
6
6
  }
7
7
  isReservedWord(ctx, s) {
8
- return s && typeof s === 'string' &&
9
- reservedWords.includes(s.toLowerCase());
8
+ return s && typeof s === 'string' && reservedWords.includes(s.toLowerCase());
10
9
  }
11
10
  serialize(ctx, type, o, defFn) {
12
11
  switch (type) {
@@ -33,30 +32,31 @@ export class OracleSerializer {
33
32
  _serializeSelect(ctx, o, defFn) {
34
33
  let out = defFn(ctx, o);
35
34
  const limit = o.limit || 0;
36
- const offset = Math.max((o.offset || 0), 0);
35
+ const offset = Math.max(o.offset || 0, 0);
37
36
  if (limit || offset) {
38
37
  if (ctx.dialectVersion && ctx.dialectVersion >= '12') {
39
38
  if (offset)
40
- out += '\nOFFSET ' + offset + ' ROWS' +
41
- (limit ? ' FETCH NEXT ' + limit + ' ROWS ONLY' : '');
39
+ out += '\nOFFSET ' + offset + ' ROWS' + (limit ? ' FETCH NEXT ' + limit + ' ROWS ONLY' : '');
42
40
  else
43
41
  out += '\nFETCH FIRST ' + limit + ' ROWS ONLY';
44
42
  }
45
43
  else {
46
44
  if (offset || o.orderBy) {
47
- out = 'select * from (\n\t' +
48
- 'select /*+ first_rows(' + (limit || 100) +
49
- ') */ t.*, rownum row$number from (\n\t' +
50
- out + '\n\b' +
51
- ') t' +
52
- (limit ? ' where rownum <= ' + (limit + offset) : '') + '\n\b)';
45
+ out =
46
+ 'select * from (\n\t' +
47
+ 'select /*+ first_rows(' +
48
+ (limit || 100) +
49
+ ') */ t.*, rownum row$number from (\n\t' +
50
+ out +
51
+ '\n\b' +
52
+ ') t' +
53
+ (limit ? ' where rownum <= ' + (limit + offset) : '') +
54
+ '\n\b)';
53
55
  if (offset)
54
56
  out += ' where row$number >= ' + (offset + 1);
55
57
  }
56
58
  else {
57
- out = 'select * from (\n\t' +
58
- out + '\n\b' +
59
- ') where rownum <= ' + limit;
59
+ out = 'select * from (\n\t' + out + '\n\b' + ') where rownum <= ' + limit;
60
60
  }
61
61
  }
62
62
  }
@@ -82,8 +82,7 @@ export class OracleSerializer {
82
82
  return defFn(ctx, { ...o, operatorType: OperatorType.isNot, symbol: 'not in' });
83
83
  }
84
84
  else if ((o.right?.expression && o.right?.expression === 'null') ||
85
- (o.right && o.right?.value == null &&
86
- (!o.right.expression || o.right.expression.startsWith(':')))) {
85
+ (o.right && o.right?.value == null && (!o.right.expression || o.right.expression.startsWith(':')))) {
87
86
  if (o.right.expression?.startsWith(':')) {
88
87
  const s = o.right.expression.substring(1);
89
88
  if (ctx.params)
@@ -105,7 +104,7 @@ export class OracleSerializer {
105
104
  _serializeStringValue(ctx, o, defFn) {
106
105
  if (typeof o === 'string') {
107
106
  if (o.match(/^\d{4}-\d{2}-\d{2}$/))
108
- return 'to_date(' + o + ', \'yyyy-mm-dd\')';
107
+ return 'to_date(' + o + ", 'yyyy-mm-dd')";
109
108
  if (o.match(/^\d{4}-\d{2}-\d{2}T/))
110
109
  return `to_timestamp_tz('${o}','yyyy-mm-dd"T"hh24:mi:sstzh:tzm')`;
111
110
  }
@@ -113,29 +112,29 @@ export class OracleSerializer {
113
112
  }
114
113
  _serializeDateValue(ctx, o, defFn) {
115
114
  const s = defFn(ctx, o);
116
- return s && (s.length <= 12 ?
117
- 'to_date(' + s + ', \'yyyy-mm-dd\')' :
118
- 'to_date(' + s + ', \'yyyy-mm-dd hh24:mi:ss\')');
115
+ return s && (s.length <= 12 ? 'to_date(' + s + ", 'yyyy-mm-dd')" : 'to_date(' + s + ", 'yyyy-mm-dd hh24:mi:ss')");
119
116
  }
120
117
  _serializeBooleanValue(_ctx, o) {
121
- return o == null ? 'null' : (o ? '1' : '0');
118
+ return o == null ? 'null' : o ? '1' : '0';
122
119
  }
123
120
  // noinspection JSUnusedLocalSymbols
124
121
  _serializeStringAGG(ctx, o,
125
122
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
126
123
  defFn) {
127
- return 'listagg(' + o.field +
128
- ',\'' + o.delimiter + '\') within group (' +
129
- (o.orderBy ? o.orderBy : 'order by null') + ')' +
130
- (o.alias ? ' ' + o.alias : '');
124
+ return ('listagg(' +
125
+ o.field +
126
+ ",'" +
127
+ o.delimiter +
128
+ "') within group (" +
129
+ (o.orderBy ? o.orderBy : 'order by null') +
130
+ ')' +
131
+ (o.alias ? ' ' + o.alias : ''));
131
132
  }
132
133
  // noinspection JSUnusedLocalSymbols
133
134
  _serializeSequenceGetter(ctx, o,
134
135
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
135
136
  defFn) {
136
- return o.genName + '.' +
137
- (o.next ? 'nextval' : 'currval') +
138
- (o.alias ? ' ' + o.alias : '');
137
+ return o.genName + '.' + (o.next ? 'nextval' : 'currval') + (o.alias ? ' ' + o.alias : '');
139
138
  }
140
139
  _serializeReturning() {
141
140
  return '';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sqb/oracle-dialect",
3
3
  "description": "SQB serialization extension for Oracle database",
4
- "version": "4.11.2",
4
+ "version": "4.12.0",
5
5
  "author": "Panates",
6
6
  "contributors": [
7
7
  "Eray Hanoglu <e.hanoglu@panates.com>",
@@ -30,10 +30,11 @@
30
30
  "clean": "npm run clean:src | npm run clean:dist | npm run clean:cover",
31
31
  "clean:src": "ts-cleanup -s src --all",
32
32
  "clean:dist": "rimraf ../../build/oracle-dialect",
33
- "clean:cover": "rimraf ../../coverage/oracle-dialect"
33
+ "clean:cover": "rimraf ../../coverage/oracle-dialect",
34
+ "format": "prettier . --write --log-level=warn"
34
35
  },
35
36
  "peerDependencies": {
36
- "@sqb/builder": "^4.11.2"
37
+ "@sqb/builder": "^4.12.0"
37
38
  },
38
39
  "engines": {
39
40
  "node": ">=16.0",