Skip to content

Commit

Permalink
Fixes with BulkInsert
Browse files Browse the repository at this point in the history
  • Loading branch information
amigin committed Oct 25, 2024
1 parent e2e5e04 commit 18423a7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion my-postgres-core/src/connection_sql_operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion my-postgres-core/src/my_postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 18423a7

Please sign in to comment.