|
@@ -1490,7 +1490,9 @@ void HqlGram::doAddAssignment(IHqlExpression * transform, IHqlExpression * _fiel
|
|
|
void HqlGram::appendTransformAssign(IHqlExpression * transform, IHqlExpression * to, IHqlExpression * _from, const attribute& errpos)
|
|
|
{
|
|
|
LinkedHqlExpr from = _from;
|
|
|
- if (from->isConstant())
|
|
|
+ if (isNull(from))
|
|
|
+ from.setown(createNullExpr(to));
|
|
|
+ else if (from->isConstant())
|
|
|
from.setown(ensureExprType(from, to->queryType()));
|
|
|
if (to->isDataset() && !recordTypesMatch(from, to))
|
|
|
{
|
|
@@ -1959,7 +1961,7 @@ void HqlGram::doCheckAssignedNormalizeTransform(HqlExprArray * assigns, IHqlExpr
|
|
|
if (cur->hasProperty(virtualAtom))
|
|
|
{
|
|
|
reportWarning(ERR_TRANS_NOVALUE4FIELD, errpos.pos, "Transform does not supply a value for field \"%s\"", fldName.str());
|
|
|
- OwnedHqlExpr null = createNullExpr(cur->queryType());
|
|
|
+ OwnedHqlExpr null = createNullExpr(cur);
|
|
|
if (assigns)
|
|
|
assigns->append(*createAssign(LINK(targetSelected), LINK(null)));
|
|
|
else
|
|
@@ -2268,6 +2270,35 @@ void HqlGram::addField(const attribute &errpos, _ATOM name, ITypeInfo *_type, IH
|
|
|
value = newValue;
|
|
|
}
|
|
|
}
|
|
|
+ if (attrs)
|
|
|
+ {
|
|
|
+ HqlExprArray allAttrs;
|
|
|
+ attrs->unwindList(allAttrs, no_comma);
|
|
|
+ IHqlExpression * defaultAttr = queryProperty(defaultAtom, allAttrs);
|
|
|
+ if (defaultAttr)
|
|
|
+ {
|
|
|
+ IHqlExpression * defaultValue = defaultAttr->queryChild(0);
|
|
|
+ if (defaultValue)
|
|
|
+ {
|
|
|
+ ITypeInfo * defvalueType = defaultValue->queryType();
|
|
|
+ if (defvalueType != expectedType)
|
|
|
+ {
|
|
|
+ if (!expectedType->assignableFrom(defvalueType->queryPromotedType()))
|
|
|
+ canNotAssignTypeError(fieldType,defvalueType,errpos);
|
|
|
+ if (castLosesInformation(expectedType, defvalueType))
|
|
|
+ reportWarning(ERR_TYPE_INCOMPATIBLE, errpos.pos, "%s", "Default value too large");
|
|
|
+ if (expectedType->getTypeCode() != type_row)
|
|
|
+ {
|
|
|
+ IHqlExpression * newValue = ensureExprType(defaultValue, expectedType);
|
|
|
+ allAttrs.zap(*defaultAttr);
|
|
|
+ allAttrs.append(*createAttribute(defaultAtom, newValue));
|
|
|
+ attrs->Release();
|
|
|
+ attrs = createComma(allAttrs);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
switch (fieldType->getTypeCode())
|
|
|
{
|
|
@@ -6646,7 +6677,7 @@ IHqlExpression * HqlGram::checkOutputRecord(IHqlExpression *record, const attrib
|
|
|
allConstant = false; // no point reporting this as well.
|
|
|
|
|
|
HqlExprArray args;
|
|
|
- args.append(*createNullExpr(field->queryType()));
|
|
|
+ args.append(*createNullExpr(field));
|
|
|
newField.setown(field->clone(args));
|
|
|
}
|
|
|
|