sb.append(selectItemString); } else { final ColumnType columnType = _selectItem.getExpectedColumnType(); final String sqlValue = FormatHelper.formatSqlValue(columnType, operand); sb.append(sqlValue);
sb.append(selectItemString); } else { final ColumnType columnType = _selectItem.getExpectedColumnType(); final String sqlValue = FormatHelper.formatSqlValue(columnType, operand); sb.append(sqlValue);
} else if (operand instanceof Date) { final SimpleDateFormat dateFormat; ColumnType expectedColumnType = selectItem.getExpectedColumnType(); if (expectedColumnType == ColumnType.DATE) {
} else if (operand instanceof Date) { final SimpleDateFormat dateFormat; ColumnType expectedColumnType = selectItem.getExpectedColumnType(); if (expectedColumnType == ColumnType.DATE) {
final ColumnType expectedColumnType = leftSelectItem.getExpectedColumnType(); final Object result; if (expectedColumnType == null) {
final ColumnType expectedColumnType = leftSelectItem.getExpectedColumnType(); final Object result; if (expectedColumnType == null) {
@Override public String rewriteFilterItem(FilterItem item) { final SelectItem selectItem = item.getSelectItem(); final Object itemOperand = item.getOperand(); final OperatorType operator = item.getOperator(); if (null != selectItem && itemOperand != null) { ColumnType columnType = selectItem.getExpectedColumnType(); if (columnType != null) { if (columnType.isTimeBased()) { // special logic for DB2 based time operands. StringBuilder sb = new StringBuilder(); sb.append(selectItem.getSameQueryAlias(true)); final Object operand = FilterItem.appendOperator(sb, itemOperand, operator); if (operand instanceof SelectItem) { final String selectItemString = ((SelectItem) operand).getSameQueryAlias(true); sb.append(selectItemString); } else { Date date = TimeComparator.toDate(itemOperand); if (date == null) { throw new IllegalStateException("Could not convert " + itemOperand + " to date"); } final String sqlValue = FormatHelper.formatSqlTime(columnType, date, true, "('", "')"); sb.append(sqlValue); } return sb.toString(); } } } return super.rewriteFilterItem(item); }
@Override public String rewriteFilterItem(FilterItem item) { final SelectItem selectItem = item.getSelectItem(); final Object itemOperand = item.getOperand(); final OperatorType operator = item.getOperator(); if (null != selectItem && itemOperand != null) { ColumnType columnType = selectItem.getExpectedColumnType(); if (columnType != null) { if (columnType.isTimeBased()) { // special logic for DB2 based time operands. StringBuilder sb = new StringBuilder(); sb.append(selectItem.getSameQueryAlias(true)); final Object operand = FilterItem.appendOperator(sb, itemOperand, operator); if (operand instanceof SelectItem) { final String selectItemString = ((SelectItem) operand).getSameQueryAlias(true); sb.append(selectItemString); } else { Date date = TimeComparator.toDate(itemOperand); if (date == null) { throw new IllegalStateException("Could not convert " + itemOperand + " to date"); } final String sqlValue = FormatHelper.formatSqlTime(columnType, date, true, "('", "')"); sb.append(sqlValue); } return sb.toString(); } } } return super.rewriteFilterItem(item); }
/** * Tries to infer the {@link ColumnType} of this {@link SelectItem}. For expression based select items, this is not * possible, and the method will return null. * * @return */ public ColumnType getExpectedColumnType() { if (_subQuerySelectItem != null) { return _subQuerySelectItem.getExpectedColumnType(); } if (_function != null) { if (_column != null) { return _function.getExpectedColumnType(_column.getType()); } else { return _function.getExpectedColumnType(null); } } if (_column != null) { return _column.getType(); } return null; }
/** * Tries to infer the {@link ColumnType} of this {@link SelectItem}. For expression based select items, this is not * possible, and the method will return null. * * @return */ public ColumnType getExpectedColumnType() { if (_subQuerySelectItem != null) { return _subQuerySelectItem.getExpectedColumnType(); } if (_function != null) { if (_column != null) { return _function.getExpectedColumnType(_column.getType()); } else { return _function.getExpectedColumnType(null); } } if (_column != null) { return _column.getType(); } return null; }