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

Update transforms.py #3625

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
19 changes: 17 additions & 2 deletions cumulusci/core/source_transforms/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import functools
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also update the tests?

import io
import os
import re
import shutil
import typing as T
import zipfile
Expand Down Expand Up @@ -338,10 +339,24 @@ def get_replace_string(self, context: TaskContext) -> str:
)

try:
record_id = results["records"][0]["Id"]
# Extract the first column name using regular expression
column_name = re.search(r"\s*select\s+(\w+)", self.replace_record_id_query, re.IGNORECASE)
if column_name:
column_name = column_name.group(1)
else:
# Defaults to Id
column_name = "Id"

except ValueError:
raise CumulusCIException(
"Unable to parse column name from replace_record_id_query. Please check format."
)

try:
record_id = results["records"][0][column_name]
except KeyError:
raise CumulusCIException(
"Results from the replace_record_id_query did not include an 'Id'. Please ensure the 'Id' field is included in your query's SELECT clause."
f"Results from the replace_record_id_query did not include an '{column_name}'. Please ensure the '{column_name}' field is included in your query's SELECT clause."
GeekStewie marked this conversation as resolved.
Show resolved Hide resolved
)
return record_id

Expand Down