Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@W-17412267: Fix for records not being inserted when threshold 0 #3857

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading