orange-orm 4.7.10-beta.3 → 4.7.11-beta.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/dist/index.browser.mjs +264 -113
- package/dist/index.mjs +431 -122
- package/package.json +1 -1
- package/src/bunSqlite/newTransaction.js +2 -0
- package/src/d1/newTransaction.js +2 -0
- package/src/map.d.ts +39 -0
- package/src/map2.d.ts +5 -5
- package/src/mssql/formatBigintIn.js +5 -0
- package/src/mssql/newTransaction.js +4 -0
- package/src/mssql/pool/newGenericPool.js +7 -0
- package/src/mssql/wrapQuery.js +1 -0
- package/src/mySql/formatBigintOut.js +11 -0
- package/src/mySql/newTransaction.js +2 -0
- package/src/nodeSqlite/newTransaction.js +2 -0
- package/src/oracle/formatBigintOut.js +12 -0
- package/src/oracle/formatDateOut.js +4 -1
- package/src/oracle/insertSql.js +2 -2
- package/src/oracle/mergeSql.js +1 -1
- package/src/oracle/newTransaction.js +2 -0
- package/src/pg/formatDateOut.js +4 -1
- package/src/sap/encodeBigint.js +8 -0
- package/src/sap/formatBigintIn.js +5 -0
- package/src/sap/formatBigintOut.js +11 -0
- package/src/sap/formatDateOut.js +4 -1
- package/src/sap/insertSql.js +1 -1
- package/src/sap/mergeSql.js +1 -1
- package/src/sap/newTransaction.js +4 -0
- package/src/sqlite/formatBigintOut.js +11 -0
- package/src/sqlite/lastInsertedSql.js +1 -1
- package/src/sqlite3/newTransaction.js +2 -0
- package/src/table/column/bigint/newDecode.js +18 -0
- package/src/table/column/bigint/newEncode.js +44 -0
- package/src/table/column/bigint.js +16 -0
- package/src/table/column/date/formatOut.js +3 -1
- package/src/table/column/formatOutGeneric.js +14 -0
- package/src/table/column/in.js +7 -5
- package/src/table/column/json.js +2 -2
- package/src/table/column.js +5 -0
- package/src/table/commands/newGetLastInsertedCommandCore.js +11 -1
- package/src/table/commands/newInsertCommandCore.js +1 -1
- package/src/tedious/formatBigintOut.js +11 -0
- package/src/tedious/formatDateOut.js +4 -1
- package/src/tedious/formatJSONOut.js +4 -1
- package/src/tedious/insertSql.js +5 -5
- package/src/tedious/mergeSql.js +3 -3
- package/src/tedious/newTransaction.js +2 -0
- package/src/tedious/outputInsertedSql.js +11 -2
- package/src/table/column/json/formatOut.js +0 -12
|
@@ -10,7 +10,17 @@ function newGetLastInsertedCommandCore(context, table, row) {
|
|
|
10
10
|
return newParameterized(sql, parameters);
|
|
11
11
|
|
|
12
12
|
function columnNames() {
|
|
13
|
-
return table._columns.map(
|
|
13
|
+
return table._columns.map(formatColumn).join(',');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function formatColumn(column) {
|
|
17
|
+
const formatted = column.formatOut ? column.formatOut(context) + ' as ' + quote(context, column._dbName) : quote(context, column._dbName);
|
|
18
|
+
if (column.dbNull === null)
|
|
19
|
+
return formatted;
|
|
20
|
+
else {
|
|
21
|
+
const encoded = column.encode.unsafe(context, column.dbNull);
|
|
22
|
+
return `CASE WHEN ${formatted}=${encoded} THEN null ELSE ${formatted} END`;
|
|
23
|
+
}
|
|
14
24
|
}
|
|
15
25
|
|
|
16
26
|
function whereSql() {
|
|
@@ -13,7 +13,7 @@ function newInsertCommandCore(context, table, row, options = {}) {
|
|
|
13
13
|
if (row['__' + column.alias] !== undefined) {
|
|
14
14
|
let encoded = column.encode(context, row[alias]);
|
|
15
15
|
if (encoded.parameters.length > 0) {
|
|
16
|
-
values.push(
|
|
16
|
+
values.push(encoded.sql());
|
|
17
17
|
parameters.push(encoded.parameters[0]);
|
|
18
18
|
} else
|
|
19
19
|
values.push(encoded.sql());
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const quote = require('./quote');
|
|
2
|
+
|
|
3
|
+
function formatBigintOut(column, alias) {
|
|
4
|
+
const quotedCol = quote(column._dbName);
|
|
5
|
+
if (alias)
|
|
6
|
+
return `CAST(${alias}.${quotedCol} AS NVARCHAR(20))`;
|
|
7
|
+
else
|
|
8
|
+
return `CAST(${quotedCol} AS NVARCHAR(20))`;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
module.exports = formatBigintOut;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
const quote = require('./quote');
|
|
2
2
|
|
|
3
3
|
function formatDateOut(column, alias) {
|
|
4
|
-
|
|
4
|
+
if (alias)
|
|
5
|
+
return `CONVERT(VARCHAR, ${alias}.${quote(column._dbName)}, 121)`;
|
|
6
|
+
else
|
|
7
|
+
return `CONVERT(VARCHAR, ${quote(column._dbName)}, 121)`;
|
|
5
8
|
}
|
|
6
9
|
|
|
7
10
|
module.exports = formatDateOut;
|
package/src/tedious/insertSql.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
let outputInsertedSql = require('./outputInsertedSql');
|
|
2
2
|
let mergeSql = require('./mergeSql');
|
|
3
3
|
|
|
4
|
-
function getSqlTemplate(
|
|
4
|
+
function getSqlTemplate(context, _table, _row, options) {
|
|
5
5
|
if (hasConcurrency(_table, options) && hasColumns())
|
|
6
|
-
return mergeSql.apply(null, [...arguments]
|
|
6
|
+
return mergeSql.apply(null, [...arguments]);
|
|
7
7
|
else
|
|
8
|
-
return insertSql.apply(null, [...arguments]
|
|
8
|
+
return insertSql.apply(null, [...arguments]);
|
|
9
9
|
|
|
10
10
|
function hasColumns() {
|
|
11
11
|
for(let p in _row) {
|
|
@@ -25,7 +25,7 @@ function hasConcurrency(table,options) {
|
|
|
25
25
|
return options.concurrency === 'skipOnConflict' || options.concurrency === 'overwrite';
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
function insertSql(table, row) {
|
|
28
|
+
function insertSql(context, table, row) {
|
|
29
29
|
let columnNames = [];
|
|
30
30
|
let values = [];
|
|
31
31
|
let sql = `INSERT INTO [${table._dbName}] `;
|
|
@@ -60,7 +60,7 @@ function insertSql(table, row) {
|
|
|
60
60
|
|
|
61
61
|
function outputInserted() {
|
|
62
62
|
|
|
63
|
-
return ' ' + outputInsertedSql(table) + ' ';
|
|
63
|
+
return ' ' + outputInsertedSql(context, table) + ' ';
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
}
|
package/src/tedious/mergeSql.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const outputInsertedSql = require('./outputInsertedSql');
|
|
2
2
|
|
|
3
|
-
function insertSql(table, row, options) {
|
|
3
|
+
function insertSql(context, table, row, options) {
|
|
4
4
|
|
|
5
5
|
let columnNames = [];
|
|
6
6
|
let conflictColumnUpdateSql = '';
|
|
@@ -11,9 +11,9 @@ function insertSql(table, row, options) {
|
|
|
11
11
|
const matched = whenMatched();
|
|
12
12
|
let sql;
|
|
13
13
|
if (matched)
|
|
14
|
-
sql = `MERGE INTO [${table._dbName}] AS target USING (SELECT ${values.join(',')}) AS source ON ${join()} WHEN MATCHED THEN ${matched} WHEN NOT MATCHED THEN ${whenNotMatched()} ${outputInsertedSql(table)};`;
|
|
14
|
+
sql = `MERGE INTO [${table._dbName}] AS target USING (SELECT ${values.join(',')}) AS source ON ${join()} WHEN MATCHED THEN ${matched} WHEN NOT MATCHED THEN ${whenNotMatched()} ${outputInsertedSql(context, table)};`;
|
|
15
15
|
else
|
|
16
|
-
sql = `MERGE INTO [${table._dbName}] AS target USING (SELECT ${values.join(',')}) AS source ON ${join()} WHEN NOT MATCHED THEN ${whenNotMatched()} ${outputInsertedSql(table)};`;
|
|
16
|
+
sql = `MERGE INTO [${table._dbName}] AS target USING (SELECT ${values.join(',')}) AS source ON ${join()} WHEN NOT MATCHED THEN ${whenNotMatched()} ${outputInsertedSql(context, table)};`;
|
|
17
17
|
return sql;
|
|
18
18
|
|
|
19
19
|
function join() {
|
|
@@ -6,6 +6,7 @@ const limitAndOffset = require('./limitAndOffset');
|
|
|
6
6
|
const insertSql = require('./insertSql');
|
|
7
7
|
const getManyDto = require('./getManyDto');
|
|
8
8
|
const formatDateOut = require('./formatDateOut');
|
|
9
|
+
const formatBigintOut = require('./formatBigintOut');
|
|
9
10
|
const formatJSONOut = require('./formatJSONOut');
|
|
10
11
|
const insert = require('./insert');
|
|
11
12
|
const quote = require('./quote');
|
|
@@ -27,6 +28,7 @@ function newResolveTransaction(domain, pool, { readonly = false } = {}) {
|
|
|
27
28
|
rdb.insertSql = insertSql;
|
|
28
29
|
rdb.insert = insert;
|
|
29
30
|
rdb.formatDateOut = formatDateOut;
|
|
31
|
+
rdb.formatBigintOut = formatBigintOut;
|
|
30
32
|
rdb.formatJSONOut = formatJSONOut;
|
|
31
33
|
rdb.multipleStatements = true;
|
|
32
34
|
rdb.begin = 'BEGIN TRANSACTION';
|
|
@@ -1,11 +1,20 @@
|
|
|
1
|
-
function outputInsertedSql(table) {
|
|
1
|
+
function outputInsertedSql(context, table) {
|
|
2
2
|
let separator = '';
|
|
3
3
|
let result = 'OUTPUT ';
|
|
4
4
|
for (let i = 0; i < table._columns.length; i++) {
|
|
5
|
-
result += separator +
|
|
5
|
+
result += separator + formatColumn(table._columns[i]);
|
|
6
6
|
separator = ',';
|
|
7
7
|
}
|
|
8
8
|
return result;
|
|
9
|
+
|
|
10
|
+
function formatColumn(column) {
|
|
11
|
+
if (column.formatOut)
|
|
12
|
+
return column.formatOut(context, 'INSERTED');
|
|
13
|
+
else
|
|
14
|
+
return `INSERTED.[${column._dbName}]`;
|
|
15
|
+
}
|
|
9
16
|
}
|
|
10
17
|
|
|
18
|
+
|
|
19
|
+
|
|
11
20
|
module.exports = outputInsertedSql;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
var getSessionSingleton = require('../../getSessionSingleton');
|
|
2
|
-
const quote = require('../../quote');
|
|
3
|
-
|
|
4
|
-
function formatOut(context, column, alias) {
|
|
5
|
-
var formatColumn = getSessionSingleton(context, 'formatJSONOut');
|
|
6
|
-
if (formatColumn)
|
|
7
|
-
return formatColumn(column, alias);
|
|
8
|
-
else
|
|
9
|
-
return `${alias}.${quote(context, column._dbName)}`;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
module.exports = formatOut;
|