From 18423a70dfd633c541dd39033fff284e58d5a0e2 Mon Sep 17 00:00:00 2001 From: amigin Date: Fri, 25 Oct 2024 15:44:21 +0400 Subject: [PATCH] Fixes with BulkInsert --- my-postgres-core/src/connection_sql_operations.rs | 2 +- my-postgres-core/src/my_postgres.rs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/my-postgres-core/src/connection_sql_operations.rs b/my-postgres-core/src/connection_sql_operations.rs index beccdd9..487ce53 100644 --- a/my-postgres-core/src/connection_sql_operations.rs +++ b/my-postgres-core/src/connection_sql_operations.rs @@ -349,7 +349,7 @@ impl PostgresConnection { let key = entity.get_primary_key_as_single_string(); if has_entities.contains(&key) { - panic!("Duplicated entity in bulk_insert_or_update_db_entity for table: {}. PrimaryKey: {}", table_name, key); + return Err(MyPostgresError::Other(format!("Duplicated entity in bulk_insert_or_update_db_entity for table: {}. PrimaryKey: {}", table_name, key))); } has_entities.insert(key); diff --git a/my-postgres-core/src/my_postgres.rs b/my-postgres-core/src/my_postgres.rs index 0af2c9e..5b9bfda 100644 --- a/my-postgres-core/src/my_postgres.rs +++ b/my-postgres-core/src/my_postgres.rs @@ -358,7 +358,9 @@ impl MyPostgres { #[cfg(feature = "with-logs-and-telemetry")] telemetry_context: Option<&MyTelemetryContext>, ) -> Result<(), MyPostgresError> { if entities.len() == 0 { - panic!("Attempt to bulk_insert_or_update_db_entity 0 entities"); + return Err(MyPostgresError::Other( + "Attempt to bulk_insert_or_update_db_entity 0 entities".to_string(), + )); } self.connection