|
@@ -21,10 +21,10 @@ export class BulkInserter {
|
|
|
try {
|
|
try {
|
|
|
// Handle specific table names with Prisma models
|
|
// Handle specific table names with Prisma models
|
|
|
const tableName = sectionData.tableName;
|
|
const tableName = sectionData.tableName;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
for (let i = 0; i < totalRows; i += batchSize) {
|
|
for (let i = 0; i < totalRows; i += batchSize) {
|
|
|
const batch = sectionData.data.slice(i, i + batchSize);
|
|
const batch = sectionData.data.slice(i, i + batchSize);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if (batch.length === 0) continue;
|
|
if (batch.length === 0) continue;
|
|
|
|
|
|
|
|
// Prepare data for insertion with proper field mapping
|
|
// Prepare data for insertion with proper field mapping
|
|
@@ -32,14 +32,14 @@ export class BulkInserter {
|
|
|
const mappedRow: any = {
|
|
const mappedRow: any = {
|
|
|
importId: importId
|
|
importId: importId
|
|
|
};
|
|
};
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// Map the row data to match Prisma model field names
|
|
// Map the row data to match Prisma model field names
|
|
|
Object.keys(row).forEach(key => {
|
|
Object.keys(row).forEach(key => {
|
|
|
// Convert snake_case to camelCase for Prisma model compatibility
|
|
// Convert snake_case to camelCase for Prisma model compatibility
|
|
|
const camelKey = key.replace(/_([a-z])/g, (g) => g[1].toUpperCase());
|
|
const camelKey = key.replace(/_([a-z])/g, (g) => g[1].toUpperCase());
|
|
|
mappedRow[camelKey] = row[key];
|
|
mappedRow[camelKey] = row[key];
|
|
|
});
|
|
});
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
return mappedRow;
|
|
return mappedRow;
|
|
|
});
|
|
});
|
|
|
|
|
|
|
@@ -75,10 +75,10 @@ export class BulkInserter {
|
|
|
|
|
|
|
|
private buildInsertQuery(tableName: string, values: any[]): string {
|
|
private buildInsertQuery(tableName: string, values: any[]): string {
|
|
|
if (values.length === 0) return '';
|
|
if (values.length === 0) return '';
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
const keys = Object.keys(values[0]);
|
|
const keys = Object.keys(values[0]);
|
|
|
const columns = keys.join(', ');
|
|
const columns = keys.join(', ');
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
const placeholders = values.map(row => {
|
|
const placeholders = values.map(row => {
|
|
|
const valuesList = keys.map(key => {
|
|
const valuesList = keys.map(key => {
|
|
|
const value = row[key];
|
|
const value = row[key];
|