@sqb/oracle-dialect 4.20.7 → 4.21.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/package.json +9 -25
- package/cjs/index.js +0 -5
- package/cjs/oracle-serializer.js +0 -176
- package/cjs/package.json +0 -3
- package/esm/package.json +0 -3
- package/types/index.d.cts +0 -1
- /package/{types/index.d.ts → index.d.ts} +0 -0
- /package/{esm/index.js → index.js} +0 -0
- /package/{types/oracle-serializer.d.ts → oracle-serializer.d.ts} +0 -0
- /package/{esm/oracle-serializer.js → oracle-serializer.js} +0 -0
package/package.json
CHANGED
|
@@ -1,33 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sqb/oracle-dialect",
|
|
3
3
|
"description": "SQB serialization extension for Oracle database",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.21.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": "^4.
|
|
11
|
+
"@sqb/builder": "^4.21.1"
|
|
12
12
|
},
|
|
13
13
|
"type": "module",
|
|
14
|
+
"module": "./index.js",
|
|
15
|
+
"types": "./index.d.ts",
|
|
14
16
|
"exports": {
|
|
15
17
|
".": {
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
"default": "./esm/index.js"
|
|
19
|
-
},
|
|
20
|
-
"require": {
|
|
21
|
-
"types": "./types/index.d.cts",
|
|
22
|
-
"default": "./cjs/index.js"
|
|
23
|
-
},
|
|
24
|
-
"default": "./esm/index.js"
|
|
18
|
+
"types": "./index.d.ts",
|
|
19
|
+
"default": "./index.js"
|
|
25
20
|
},
|
|
26
21
|
"./package.json": "./package.json"
|
|
27
22
|
},
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": ">=20.0"
|
|
25
|
+
},
|
|
31
26
|
"contributors": [
|
|
32
27
|
"Eray Hanoglu <e.hanoglu@panates.com>",
|
|
33
28
|
"Ilker Gurelli <i.gurelli@panates.com>"
|
|
@@ -37,17 +32,6 @@
|
|
|
37
32
|
"url": "https://github.com/panates/sqb.git",
|
|
38
33
|
"directory": "packages/oracle-dialect"
|
|
39
34
|
},
|
|
40
|
-
"engines": {
|
|
41
|
-
"node": ">=18.0"
|
|
42
|
-
},
|
|
43
|
-
"files": [
|
|
44
|
-
"bin/",
|
|
45
|
-
"cjs/",
|
|
46
|
-
"esm/",
|
|
47
|
-
"types/",
|
|
48
|
-
"LICENSE",
|
|
49
|
-
"README.md"
|
|
50
|
-
],
|
|
51
35
|
"keywords": [
|
|
52
36
|
"sqb",
|
|
53
37
|
"oracle",
|
package/cjs/index.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const builder_1 = require("@sqb/builder");
|
|
4
|
-
const oracle_serializer_js_1 = require("./oracle-serializer.js");
|
|
5
|
-
builder_1.SerializerRegistry.register(new oracle_serializer_js_1.OracleSerializer());
|
package/cjs/oracle-serializer.js
DELETED
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OracleSerializer = void 0;
|
|
4
|
-
const builder_1 = require("@sqb/builder");
|
|
5
|
-
const reservedWords = ['comment', 'dual'];
|
|
6
|
-
class OracleSerializer {
|
|
7
|
-
dialect = 'oracle';
|
|
8
|
-
isReservedWord(ctx, s) {
|
|
9
|
-
return (s && typeof s === 'string' && reservedWords.includes(s.toLowerCase()));
|
|
10
|
-
}
|
|
11
|
-
serialize(ctx, type, o, defFn) {
|
|
12
|
-
switch (type) {
|
|
13
|
-
case builder_1.SerializationType.SELECT_QUERY:
|
|
14
|
-
return this._serializeSelect(ctx, o, defFn);
|
|
15
|
-
case builder_1.SerializationType.SELECT_QUERY_FROM:
|
|
16
|
-
return this._serializeFrom(ctx, o, defFn);
|
|
17
|
-
case builder_1.SerializationType.COMPARISON_EXPRESSION:
|
|
18
|
-
return this._serializeComparison(ctx, o, defFn);
|
|
19
|
-
case builder_1.SerializationType.STRING_VALUE:
|
|
20
|
-
return this._serializeStringValue(ctx, o, defFn);
|
|
21
|
-
case builder_1.SerializationType.DATE_VALUE:
|
|
22
|
-
return this._serializeDateValue(ctx, o, defFn);
|
|
23
|
-
case builder_1.SerializationType.BOOLEAN_VALUE:
|
|
24
|
-
return this._serializeBooleanValue(ctx, o);
|
|
25
|
-
case builder_1.SerializationType.RETURNING_BLOCK:
|
|
26
|
-
return this._serializeReturning();
|
|
27
|
-
case builder_1.SerializationType.STRINGAGG_STATEMENT:
|
|
28
|
-
return this._serializeStringAGG(ctx, o, defFn);
|
|
29
|
-
case builder_1.SerializationType.SEQUENCE_GETTER_STATEMENT:
|
|
30
|
-
return this._serializeSequenceGetter(ctx, o, defFn);
|
|
31
|
-
default:
|
|
32
|
-
break;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
_serializeSelect(ctx, o, defFn) {
|
|
36
|
-
let out = defFn(ctx, o);
|
|
37
|
-
const limit = o.limit || 0;
|
|
38
|
-
const offset = Math.max(o.offset || 0, 0);
|
|
39
|
-
if (limit || offset) {
|
|
40
|
-
if (ctx.dialectVersion && ctx.dialectVersion >= '12') {
|
|
41
|
-
if (offset)
|
|
42
|
-
out +=
|
|
43
|
-
'\nOFFSET ' +
|
|
44
|
-
offset +
|
|
45
|
-
' ROWS' +
|
|
46
|
-
(limit ? ' FETCH NEXT ' + limit + ' ROWS ONLY' : '');
|
|
47
|
-
else
|
|
48
|
-
out += '\nFETCH FIRST ' + limit + ' ROWS ONLY';
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
if (offset || o.orderBy) {
|
|
52
|
-
out =
|
|
53
|
-
'select * from (\n\t' +
|
|
54
|
-
'select /*+ first_rows(' +
|
|
55
|
-
(limit || 100) +
|
|
56
|
-
') */ t.*, rownum row$number from (\n\t' +
|
|
57
|
-
out +
|
|
58
|
-
'\n\b' +
|
|
59
|
-
') t' +
|
|
60
|
-
(limit ? ' where rownum <= ' + (limit + offset) : '') +
|
|
61
|
-
'\n\b)';
|
|
62
|
-
if (offset)
|
|
63
|
-
out += ' where row$number >= ' + (offset + 1);
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
out = 'select * from (\n\t' + out + '\n\b) where rownum <= ' + limit;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return out;
|
|
71
|
-
}
|
|
72
|
-
_serializeFrom(ctx, o, defFn) {
|
|
73
|
-
return defFn(ctx, o) || 'from dual';
|
|
74
|
-
}
|
|
75
|
-
_serializeComparison(ctx, o, defFn) {
|
|
76
|
-
if (o.right &&
|
|
77
|
-
o.right.expression?.startsWith(':') &&
|
|
78
|
-
Array.isArray(o.right?.value)) {
|
|
79
|
-
const s = o.right.expression.substring(1);
|
|
80
|
-
if (ctx.params)
|
|
81
|
-
delete ctx.params[s];
|
|
82
|
-
if (ctx.preparedParams)
|
|
83
|
-
delete ctx.preparedParams[s];
|
|
84
|
-
if (ctx.paramOptions)
|
|
85
|
-
delete ctx.paramOptions[s];
|
|
86
|
-
o.right.expression = ctx.anyToSQL(o.right.value);
|
|
87
|
-
o.right.isParam = false;
|
|
88
|
-
if (o.operatorType === 'eq')
|
|
89
|
-
return defFn(ctx, {
|
|
90
|
-
...o,
|
|
91
|
-
operatorType: builder_1.OperatorType.is,
|
|
92
|
-
symbol: 'in',
|
|
93
|
-
});
|
|
94
|
-
if (o.operatorType === 'ne')
|
|
95
|
-
return defFn(ctx, {
|
|
96
|
-
...o,
|
|
97
|
-
operatorType: builder_1.OperatorType.isNot,
|
|
98
|
-
symbol: 'not in',
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
else if ((o.right?.expression && o.right?.expression === 'null') ||
|
|
102
|
-
(o.right &&
|
|
103
|
-
o.right?.value == null &&
|
|
104
|
-
(!o.right.expression || o.right.expression.startsWith(':')))) {
|
|
105
|
-
if (o.right.expression?.startsWith(':')) {
|
|
106
|
-
const s = o.right.expression.substring(1);
|
|
107
|
-
if (ctx.params)
|
|
108
|
-
delete ctx.params[s];
|
|
109
|
-
if (ctx.preparedParams)
|
|
110
|
-
delete ctx.preparedParams[s];
|
|
111
|
-
if (ctx.paramOptions)
|
|
112
|
-
delete ctx.paramOptions[s];
|
|
113
|
-
o.right.expression = 'null';
|
|
114
|
-
o.right.isParam = false;
|
|
115
|
-
}
|
|
116
|
-
if (o.operatorType === 'eq')
|
|
117
|
-
return defFn(ctx, {
|
|
118
|
-
...o,
|
|
119
|
-
operatorType: builder_1.OperatorType.is,
|
|
120
|
-
symbol: 'is',
|
|
121
|
-
});
|
|
122
|
-
if (o.operatorType === 'ne')
|
|
123
|
-
return defFn(ctx, {
|
|
124
|
-
...o,
|
|
125
|
-
operatorType: builder_1.OperatorType.isNot,
|
|
126
|
-
symbol: 'is not',
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
return defFn(ctx, o);
|
|
130
|
-
}
|
|
131
|
-
_serializeStringValue(ctx, o, defFn) {
|
|
132
|
-
if (typeof o === 'string') {
|
|
133
|
-
if (o.match(/^\d{4}-\d{2}-\d{2}$/))
|
|
134
|
-
return 'to_date(' + o + ", 'yyyy-mm-dd')";
|
|
135
|
-
if (o.match(/^\d{4}-\d{2}-\d{2}T/))
|
|
136
|
-
return `to_timestamp_tz('${o}','yyyy-mm-dd"T"hh24:mi:sstzh:tzm')`;
|
|
137
|
-
}
|
|
138
|
-
return defFn(ctx, o);
|
|
139
|
-
}
|
|
140
|
-
_serializeDateValue(ctx, o, defFn) {
|
|
141
|
-
const s = defFn(ctx, o);
|
|
142
|
-
return (s &&
|
|
143
|
-
(s.length <= 12
|
|
144
|
-
? 'to_date(' + s + ", 'yyyy-mm-dd')"
|
|
145
|
-
: 'to_date(' + s + ", 'yyyy-mm-dd hh24:mi:ss')"));
|
|
146
|
-
}
|
|
147
|
-
_serializeBooleanValue(_ctx, o) {
|
|
148
|
-
return o == null ? 'null' : o ? '1' : '0';
|
|
149
|
-
}
|
|
150
|
-
// noinspection JSUnusedLocalSymbols
|
|
151
|
-
_serializeStringAGG(ctx, o,
|
|
152
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
153
|
-
defFn) {
|
|
154
|
-
return ('listagg(' +
|
|
155
|
-
o.field +
|
|
156
|
-
",'" +
|
|
157
|
-
o.delimiter +
|
|
158
|
-
"') within group (" +
|
|
159
|
-
(o.orderBy ? o.orderBy : 'order by null') +
|
|
160
|
-
')' +
|
|
161
|
-
(o.alias ? ' ' + o.alias : ''));
|
|
162
|
-
}
|
|
163
|
-
// noinspection JSUnusedLocalSymbols
|
|
164
|
-
_serializeSequenceGetter(ctx, o,
|
|
165
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
166
|
-
defFn) {
|
|
167
|
-
return (o.genName +
|
|
168
|
-
'.' +
|
|
169
|
-
(o.next ? 'nextval' : 'currval') +
|
|
170
|
-
(o.alias ? ' ' + o.alias : ''));
|
|
171
|
-
}
|
|
172
|
-
_serializeReturning() {
|
|
173
|
-
return '';
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
exports.OracleSerializer = OracleSerializer;
|
package/cjs/package.json
DELETED
package/esm/package.json
DELETED
package/types/index.d.cts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|