/** * @return an alias that can be used in WHERE, GROUP BY and ORDER BY clauses in the same query */ public String getSameQueryAlias(boolean includeSchemaInColumnPath) { if (_column != null) { final StringBuilder sb = new StringBuilder(); final String columnPrefix = getToStringColumnPrefix(includeSchemaInColumnPath); sb.append(columnPrefix); sb.append(_column.getQuotedName()); appendFunctionSql(sb); return sb.toString(); } final String alias = getAlias(); if (alias == null) { final String result = toStringNoAlias(includeSchemaInColumnPath).toString(); logger.debug("Could not resolve a reasonable same-query alias for SelectItem: {}", result); return result; } return alias; }
/** * @return an alias that can be used in WHERE, GROUP BY and ORDER BY clauses in the same query */ public String getSameQueryAlias(boolean includeSchemaInColumnPath) { if (_column != null) { final StringBuilder sb = new StringBuilder(); final String columnPrefix = getToStringColumnPrefix(includeSchemaInColumnPath); sb.append(columnPrefix); sb.append(_column.getQuotedName()); appendFunctionSql(sb); return sb.toString(); } final String alias = getAlias(); if (alias == null) { final String result = toStringNoAlias(includeSchemaInColumnPath).toString(); logger.debug("Could not resolve a reasonable same-query alias for SelectItem: {}", result); return result; } return alias; }
public StringBuilder toStringNoAlias(boolean includeSchemaInColumnPath) { final StringBuilder sb = new StringBuilder(); if (_column != null) { sb.append(getToStringColumnPrefix(includeSchemaInColumnPath)); sb.append(_column.getQuotedName()); } if (_expression != null) { sb.append(_expression); } if (_fromItem != null && _subQuerySelectItem != null) { if (_fromItem.getAlias() != null) { sb.append(_fromItem.getAlias() + '.'); } sb.append(_subQuerySelectItem.getSuperQueryAlias()); } appendFunctionSql(sb); return sb; }
public StringBuilder toStringNoAlias(boolean includeSchemaInColumnPath) { final StringBuilder sb = new StringBuilder(); if (_column != null) { sb.append(getToStringColumnPrefix(includeSchemaInColumnPath)); sb.append(_column.getQuotedName()); } if (_expression != null) { sb.append(_expression); } if (_fromItem != null && _subQuerySelectItem != null) { if (_fromItem.getAlias() != null) { sb.append(_fromItem.getAlias() + '.'); } sb.append(_subQuerySelectItem.getSuperQueryAlias()); } appendFunctionSql(sb); return sb; }
/** * @return the name that this SelectItem can be referenced with, if referenced from a super-query. This will usually * be the alias, but if there is no alias, then the column name will be used. * * @param includeQuotes indicates whether or not the output should include quotes, if the select item's column has * quotes associated (typically true, but false if used for presentation) */ public String getSuperQueryAlias(boolean includeQuotes) { if (_alias != null) { return _alias; } else if (_column != null) { final StringBuilder sb = new StringBuilder(); if (includeQuotes) { sb.append(_column.getQuotedName()); } else { sb.append(_column.getName()); } appendFunctionSql(sb); return sb.toString(); } else { logger.debug("Could not resolve a reasonable super-query alias for SelectItem: {}", toSql()); return toStringNoAlias().toString(); } }
/** * @return the name that this SelectItem can be referenced with, if referenced from a super-query. This will usually * be the alias, but if there is no alias, then the column name will be used. * * @param includeQuotes indicates whether or not the output should include quotes, if the select item's column has * quotes associated (typically true, but false if used for presentation) */ public String getSuperQueryAlias(boolean includeQuotes) { if (_alias != null) { return _alias; } else if (_column != null) { final StringBuilder sb = new StringBuilder(); if (includeQuotes) { sb.append(_column.getQuotedName()); } else { sb.append(_column.getName()); } appendFunctionSql(sb); return sb.toString(); } else { logger.debug("Could not resolve a reasonable super-query alias for SelectItem: {}", toSql()); return toStringNoAlias().toString(); } }