Merge 'Resolve appropriate column name for rowid alias/PK' from Preston Thorpe

closes https://github.com/tursodatabase/turso/issues/3512

Closes #3513
This commit is contained in:
Jussi Saurio
2025-10-02 06:59:18 +03:00
committed by GitHub

View File

@@ -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;
}
}