Skip to content

Commit 2a704df

Browse files
Fix for no records inserted when no records in target and threshold 0
1 parent be5c0bb commit 2a704df

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

cumulusci/tasks/bulkdata/select_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ def similarity_post_process(
292292
]:
293293
"""Processes the query results for the similarity selection strategy"""
294294
# Handle case where query returns 0 records
295-
if not query_records and not threshold:
295+
if not query_records and threshold is None:
296296
error_message = f"No records found for {sobject} in the target org."
297297
return [], [], error_message
298298

cumulusci/tasks/bulkdata/tests/test_select_utils.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,33 @@ def test_similarity_post_process_with_no_records():
403403
assert error_message == f"No records found for {sobject} in the target org."
404404

405405

406+
def test_similarity_post_process_with_no_records__zero_threshold():
407+
select_operator = SelectOperationExecutor(SelectStrategy.SIMILARITY)
408+
load_records = [["Aditya", "Salesforce"], ["Jawad", "Salesforce"]]
409+
query_records = []
410+
num_records = 2
411+
sobject = "Lead"
412+
(
413+
selected_records,
414+
insert_records,
415+
error_message,
416+
) = select_operator.select_post_process(
417+
load_records=load_records,
418+
query_records=query_records,
419+
num_records=num_records,
420+
sobject=sobject,
421+
weights=[1, 1, 1],
422+
fields=["LastName", "Company"],
423+
threshold=0,
424+
)
425+
426+
# Assert that it inserts everything
427+
assert selected_records == [None, None]
428+
assert insert_records[0] == ["Aditya", "Salesforce"]
429+
assert insert_records[1] == ["Jawad", "Salesforce"]
430+
assert error_message is None
431+
432+
406433
def test_calculate_levenshtein_distance_basic():
407434
record1 = ["hello", "world"]
408435
record2 = ["hullo", "word"]

0 commit comments

Comments
 (0)