@Override public Value getValue(Session session) { Select select = columnResolver.getSelect(); if (select != null) { HashMap<Expression, Object> values = select.getCurrentGroup(); if (values != null) { Value v = (Value) values.get(this); if (v != null) { return v; } } } Value value = columnResolver.getValue(column); if (value == null) { if (select == null) { throw DbException.get(ErrorCode.NULL_NOT_ALLOWED, getSQL()); } else { throw DbException.get(ErrorCode.MUST_GROUP_BY_COLUMN_1, getSQL()); } } if (column.getEnumerators() != null && value != ValueNull.INSTANCE) { return ValueEnum.get(column.getEnumerators(), value.getInt()); } return value; }
/** * Convert a value to this column's type using the given {@link Mode}. * <p> * Use this method in case the conversion is Mode-dependent. * * @param v the value * @param mode the database {@link Mode} to use * @return the value */ public Value convert(Value v, Mode mode) { try { return v.convertTo(type, MathUtils.convertLongToInt(precision), mode, this, getEnumerators()); } catch (DbException e) { if (e.getErrorCode() == ErrorCode.DATA_CONVERSION_ERROR_1) { String target = (table == null ? "" : table.getName() + ": ") + getCreateSQL(); throw DbException.get( ErrorCode.DATA_CONVERSION_ERROR_1, e, v.getSQL() + " (" + target + ")"); } throw e; } }
"Unable to resolve enumerators of expression"); enumerators = ((ExpressionColumn)expr).getColumn().getEnumerators();
displaySize = templateColumn.getDisplaySize(); scale = templateColumn.getScale(); enumerators = templateColumn.getEnumerators(); } else { Mode mode = database.getMode();
right = ValueExpression.get(r.convertTo(resType, MathUtils.convertLongToInt(left.getPrecision()), session.getDatabase().getMode(), column, column.getEnumerators()));