From efac598232202360f1731266786f894b013e238a Mon Sep 17 00:00:00 2001 From: PThorpe92 Date: Wed, 1 Oct 2025 21:49:42 -0400 Subject: [PATCH] Resolve appropriate column name for rowid alias/PK --- core/translate/expr.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/core/translate/expr.rs b/core/translate/expr.rs index c7558562d..ebe3e2116 100644 --- a/core/translate/expr.rs +++ b/core/translate/expr.rs @@ -4139,21 +4139,24 @@ fn determine_column_alias( return Some("rowid".to_string()); } - // For column references, use special handling + // For column references, always use the column name from the table if let Expr::Column { column, is_rowid_alias, .. } = expr { - if *is_rowid_alias { + if let Some(name) = table + .columns() + .get(*column) + .and_then(|col| col.name.clone()) + { + return Some(name); + } else if *is_rowid_alias { + // If it's a rowid alias, return "rowid" return Some("rowid".to_string()); } else { - // Get the column name from the table - return table - .columns() - .get(*column) - .and_then(|col| col.name.clone()); + return None; } }