From 27e2ee9be7ae0800138eae47ed0147a09b031478 Mon Sep 17 00:00:00 2001 From: dimitr Date: Wed, 28 Mar 2007 09:27:54 +0000 Subject: [PATCH] Small improvement partially related to CORE-1181. It allows to keep the field name if the cast source is an aggregated column. --- src/dsql/pass1.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/dsql/pass1.cpp b/src/dsql/pass1.cpp index ee6d9d4d89..c498b64262 100644 --- a/src/dsql/pass1.cpp +++ b/src/dsql/pass1.cpp @@ -8165,8 +8165,14 @@ static void pass1_union_auto_cast(dsql_nod* input, const dsc& desc, } // When a cast is created we're losing our fieldname, thus // create a alias to keep it. - if (select_item->nod_type == nod_field) { - dsql_fld* sub_field = (dsql_fld*) select_item->nod_arg[e_fld_field]; + const dsql_nod* name_node = select_item; + while (name_node->nod_type == nod_map) { + // skip all the nod_map nodes + const dsql_map* map = (dsql_map*) name_node->nod_arg[e_map_map]; + name_node = map->map_node; + } + if (name_node->nod_type == nod_field) { + dsql_fld* sub_field = (dsql_fld*) name_node->nod_arg[e_fld_field]; // Create new node for alias and copy fieldname alias_node = MAKE_node(nod_alias, e_alias_count); // Copy fieldname to a new string.