Skip to content

Commit

Permalink
Fix for records not being inserted when threshold 0
Browse files Browse the repository at this point in the history
@W-17412267: Fix for records not being inserted when threshold 0
  • Loading branch information
aditya-balachander authored Dec 13, 2024
2 parents be5c0bb + 2a704df commit 31e711b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cumulusci/tasks/bulkdata/select_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ def similarity_post_process(
]:
"""Processes the query results for the similarity selection strategy"""
# Handle case where query returns 0 records
if not query_records and not threshold:
if not query_records and threshold is None:
error_message = f"No records found for {sobject} in the target org."
return [], [], error_message

Expand Down
27 changes: 27 additions & 0 deletions cumulusci/tasks/bulkdata/tests/test_select_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,33 @@ def test_similarity_post_process_with_no_records():
assert error_message == f"No records found for {sobject} in the target org."


def test_similarity_post_process_with_no_records__zero_threshold():
select_operator = SelectOperationExecutor(SelectStrategy.SIMILARITY)
load_records = [["Aditya", "Salesforce"], ["Jawad", "Salesforce"]]
query_records = []
num_records = 2
sobject = "Lead"
(
selected_records,
insert_records,
error_message,
) = select_operator.select_post_process(
load_records=load_records,
query_records=query_records,
num_records=num_records,
sobject=sobject,
weights=[1, 1, 1],
fields=["LastName", "Company"],
threshold=0,
)

# Assert that it inserts everything
assert selected_records == [None, None]
assert insert_records[0] == ["Aditya", "Salesforce"]
assert insert_records[1] == ["Jawad", "Salesforce"]
assert error_message is None


def test_calculate_levenshtein_distance_basic():
record1 = ["hello", "world"]
record2 = ["hullo", "word"]
Expand Down

0 comments on commit 31e711b

Please sign in to comment.