Ver código fonte

Merge pull request #4043 from richardkchapman/export-decimal

HPCC-8898 #EXPORT not handling decimal types correctly

Reviewed-by: Gavin Halliday <ghalliday@hpccsystems.com>
Gavin Halliday 12 anos atrás
pai
commit
284dcd99b3
2 arquivos alterados com 14 adições e 1 exclusões
  1. 6 1
      ecl/hql/hqlexpr.cpp
  2. 8 0
      ecl/regress/export4.ecl

+ 6 - 1
ecl/hql/hqlexpr.cpp

@@ -13213,6 +13213,11 @@ void PrintLogExprTree(IHqlExpression *expr, const char *caption, bool full)
 static unsigned exportRecord(IPropertyTree *dataNode, IHqlExpression * record, unsigned & offset, bool flatten);
 static unsigned exportRecord(IPropertyTree *dataNode, IHqlExpression * record, bool flatten);
 
+static inline bool isdigit_or_underbar(unsigned char c)
+{
+    return isdigit(c) || c=='_';
+}
+
 unsigned exportField(IPropertyTree *table, IHqlExpression *field, unsigned & offset, bool flatten)
 {
     if (field->isAttribute())
@@ -13246,7 +13251,7 @@ unsigned exportField(IPropertyTree *table, IHqlExpression *field, unsigned & off
     if (!queryOriginalName(type, typeName))
         type->getECLType(typeName);
     f->setProp("@ecltype", typeName.str());
-    while (isdigit((unsigned char)typeName.charAt(typeName.length()-1)))
+    while (isdigit_or_underbar((unsigned char)typeName.charAt(typeName.length()-1)))
         typeName.remove(typeName.length()-1, 1);
     f->setProp("@type", typeName.str());
     f = table->addPropTree(f->queryName(), f);

+ 8 - 0
ecl/regress/export4.ecl

@@ -0,0 +1,8 @@
+decimalRec := RECORD
+DECIMAL3 A;
+DECIMAL3_1 B;
+END;
+LOADXML('<xml/>'); //"dummy" just to open an XML scope
+#DECLARE(out);
+#EXPORT(out, decimalRec);
+OUTPUT(%'out'%);