mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-05-01 17:53:59 +00:00
Merge branch 'master' of github.com:dbgate/dbgate
This commit is contained in:
@@ -1,21 +1,21 @@
|
|||||||
version: '3'
|
version: '3'
|
||||||
services:
|
services:
|
||||||
postgres:
|
# postgres:
|
||||||
image: postgres
|
# image: postgres
|
||||||
restart: always
|
# restart: always
|
||||||
environment:
|
# environment:
|
||||||
POSTGRES_PASSWORD: Pwd2020Db
|
# POSTGRES_PASSWORD: Pwd2020Db
|
||||||
ports:
|
# ports:
|
||||||
- 15000:5432
|
# - 15000:5432
|
||||||
|
|
||||||
mariadb:
|
# mariadb:
|
||||||
image: mariadb
|
# image: mariadb
|
||||||
command: --default-authentication-plugin=mysql_native_password
|
# command: --default-authentication-plugin=mysql_native_password
|
||||||
restart: always
|
# restart: always
|
||||||
ports:
|
# ports:
|
||||||
- 15004:3306
|
# - 15004:3306
|
||||||
environment:
|
# environment:
|
||||||
- MYSQL_ROOT_PASSWORD=Pwd2020Db
|
# - MYSQL_ROOT_PASSWORD=Pwd2020Db
|
||||||
|
|
||||||
# mysql:
|
# mysql:
|
||||||
# image: mysql:8.0.18
|
# image: mysql:8.0.18
|
||||||
@@ -26,15 +26,15 @@ services:
|
|||||||
# environment:
|
# environment:
|
||||||
# - MYSQL_ROOT_PASSWORD=Pwd2020Db
|
# - MYSQL_ROOT_PASSWORD=Pwd2020Db
|
||||||
|
|
||||||
# mssql:
|
mssql:
|
||||||
# image: mcr.microsoft.com/mssql/server
|
image: mcr.microsoft.com/mssql/server
|
||||||
# restart: always
|
restart: always
|
||||||
# ports:
|
ports:
|
||||||
# - 15002:1433
|
- 15002:1433
|
||||||
# environment:
|
environment:
|
||||||
# - ACCEPT_EULA=Y
|
- ACCEPT_EULA=Y
|
||||||
# - SA_PASSWORD=Pwd2020Db
|
- SA_PASSWORD=Pwd2020Db
|
||||||
# - MSSQL_PID=Express
|
- MSSQL_PID=Express
|
||||||
|
|
||||||
# cockroachdb:
|
# cockroachdb:
|
||||||
# image: cockroachdb/cockroach
|
# image: cockroachdb/cockroach
|
||||||
|
|||||||
@@ -135,8 +135,8 @@ const filterLocal = [
|
|||||||
// filter local testing
|
// filter local testing
|
||||||
'-MySQL',
|
'-MySQL',
|
||||||
'-MariaDB',
|
'-MariaDB',
|
||||||
'PostgreSQL',
|
'-PostgreSQL',
|
||||||
'-SQL Server',
|
'SQL Server',
|
||||||
'-SQLite',
|
'-SQLite',
|
||||||
'-CockroachDB',
|
'-CockroachDB',
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
const { createBulkInsertStreamBase } = require('dbgate-tools');
|
const { createBulkInsertStreamBase } = require('dbgate-tools');
|
||||||
const tedious = require('tedious');
|
const tedious = require('tedious');
|
||||||
const getConcreteType = require('./getConcreteType');
|
const getConcreteType = require('./getConcreteType');
|
||||||
|
const _ = require('lodash');
|
||||||
|
|
||||||
function runBulkInsertBatch(pool, tableName, writable, rows) {
|
function runBulkInsertBatch(pool, tableName, writable, rows) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
@@ -12,24 +13,34 @@ function runBulkInsertBatch(pool, tableName, writable, rows) {
|
|||||||
else resolve();
|
else resolve();
|
||||||
});
|
});
|
||||||
|
|
||||||
for (const column of writable.columnNames) {
|
const stringColumns = new Set();
|
||||||
const tcol = writable.templateColumns.find((x) => x.columnName == column);
|
|
||||||
|
|
||||||
bulkLoad.addColumn(
|
for (const column of writable.columnNames) {
|
||||||
column,
|
const tcol = writable.templateColumns.find(x => x.columnName == column);
|
||||||
tcol
|
|
||||||
? getConcreteType(tcol.driverNativeColumn.type, tcol.driverNativeColumn.dataLength)
|
const type = tcol
|
||||||
: tedious.TYPES.NVarChar,
|
? getConcreteType(tcol.driverNativeColumn.type, tcol.driverNativeColumn.dataLength)
|
||||||
{
|
: tedious.TYPES.NVarChar;
|
||||||
nullable: tcol ? !tcol.notNull : true,
|
|
||||||
length: tcol ? tcol.driverNativeColumn.dataLength : undefined,
|
if (type.type.toLowerCase().includes('char')) stringColumns.add(column);
|
||||||
precision: tcol ? tcol.driverNativeColumn.precision : undefined,
|
|
||||||
scale: tcol ? tcol.driverNativeColumn.scale : undefined,
|
bulkLoad.addColumn(column, type, {
|
||||||
}
|
nullable: tcol ? !tcol.notNull : true,
|
||||||
);
|
length: tcol ? tcol.driverNativeColumn.dataLength : undefined,
|
||||||
|
precision: tcol ? tcol.driverNativeColumn.precision : undefined,
|
||||||
|
scale: tcol ? tcol.driverNativeColumn.scale : undefined,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
pool.execBulkLoad(bulkLoad, rows);
|
const rowsMapped = rows.map(row =>
|
||||||
|
_.mapValues(row, (v, k) => {
|
||||||
|
if (stringColumns.has(k)) return v ? v.toString() : null;
|
||||||
|
return v;
|
||||||
|
})
|
||||||
|
);
|
||||||
|
// console.log('IMPORT ROWS', rowsMapped);
|
||||||
|
|
||||||
|
pool.execBulkLoad(bulkLoad, rowsMapped);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user