Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,24 @@ def upgrade() -> None:
ondelete="CASCADE",
)

sample_pt_col = next(
(
col
for col in inspector.get_columns("NMA_Chemistry_SampleInfo")
if col["name"] == "SamplePtID"
),
None,
)
Comment on lines +53 to +60
Copy link

Copilot AI Jan 13, 2026

Choose a reason for hiding this comment

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

The get_columns() call iterates through all columns to find one specific column. Consider using a more direct approach by checking if the column exists first, then retrieving its type separately, to avoid unnecessary iteration through all columns.

Copilot uses AI. Check for mistakes.
if sample_pt_col is not None and not isinstance(
sample_pt_col["type"], postgresql.UUID
):
op.alter_column(
"NMA_Chemistry_SampleInfo",
"SamplePtID",
type_=postgresql.UUID(as_uuid=True),
postgresql_using='"SamplePtID"::uuid',
)

# Ensure SamplePtID is uniquely constrained for downstream FK usage.
pk = inspector.get_pk_constraint("NMA_Chemistry_SampleInfo")
pk_columns = pk.get("constrained_columns") or []
Expand Down
Loading