fix(sql): keep column comments aligned for mixed star selects
Closes #8015
This commit is contained in:
1 parent
ca003c5e93
commit
09f8d095d2
3 files changed
+124
-1
No files matched your search
@@ -452,8 +452,17 @@ function parseSelectColumn(col: string, sources?: EditableQuerySource[]): Editab
|
||||
|
||||
function parseStarSelectColumn(col: string, sources?: EditableQuerySource[]): EditableQueryColumn | null {
|
||||
if (col === "*") {
|
||||
// An unqualified `*` is unambiguous when the query has exactly one
|
||||
// source, so it can bind to that source like a qualified `alias.*`
|
||||
// would. Without this, expandProjectionColumnsForSources cannot find a
|
||||
// matching table source (no sourceKey) and drops the star expansion
|
||||
// entirely, misaligning every result column that follows it — e.g.
|
||||
// `SELECT *, amount FROM orders` loses all result-column comments even
|
||||
// though the table has no ambiguity to resolve.
|
||||
const sourceKey = sources?.length === 1 ? sources[0]!.key : undefined;
|
||||
return {
|
||||
star: true,
|
||||
...(sourceKey ? { sourceKey } : {}),
|
||||
resultName: "*",
|
||||
expression: col,
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user