mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-30 09:13:58 +00:00
fix: do not insert second id column
This commit is contained in:
@@ -27,6 +27,8 @@ function getColumnInfo(tableInfo, columnName) {
|
|||||||
* @returns {{ shouldAddUuidPk: true, pkColumnName: string } | { shouldAddUuidPk: false }}
|
* @returns {{ shouldAddUuidPk: true, pkColumnName: string } | { shouldAddUuidPk: false }}
|
||||||
*/
|
*/
|
||||||
function getShouldAddUuidPkInfo(tableInfo) {
|
function getShouldAddUuidPkInfo(tableInfo) {
|
||||||
|
const hasIdColumn = tableInfo.columns.some((x) => x.columnName == 'id');
|
||||||
|
if (hasIdColumn && !tableInfo.primaryKey) return { shouldAddUuidPk: false };
|
||||||
const pkColumnName = tableInfo.primaryKey?.columns[0]?.columnName;
|
const pkColumnName = tableInfo.primaryKey?.columns[0]?.columnName;
|
||||||
if (!pkColumnName) return { shouldAddUuidPk: true, pkColumnName: 'id' };
|
if (!pkColumnName) return { shouldAddUuidPk: true, pkColumnName: 'id' };
|
||||||
|
|
||||||
@@ -72,7 +74,7 @@ function createCassandraBulkInsertStream(driver, stream, dbhan, name, options) {
|
|||||||
dmp.putRaw('uuid()');
|
dmp.putRaw('uuid()');
|
||||||
dmp.putRaw(', ');
|
dmp.putRaw(', ');
|
||||||
}
|
}
|
||||||
dmp.putCollection(',', writable.columnNames, (col) => dmp.putValue(row[col]));
|
dmp.putCollection(',', writable.columnNames, (col) => dmp.putValue(row[col]?.toString()));
|
||||||
dmp.putRaw(')');
|
dmp.putRaw(')');
|
||||||
await driver.query(dbhan, dmp.s, { discardResult: true });
|
await driver.query(dbhan, dmp.s, { discardResult: true });
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user