@Override public List<?> translateCommand(Command command, ExecutionContext context) { if (!supportsLiteralOnlyWithGrouping() && (command instanceof Select)) { Select select = (Select)command; if (select.getGroupBy() != null && select.getDerivedColumns().size() == 1) { DerivedColumn dc = select.getDerivedColumns().get(0); if (dc.getExpression() instanceof Literal) { dc.setExpression(select.getGroupBy().getElements().get(0)); } } } return super.translateCommand(command, context); }
private void addCast(String nativeType, DerivedColumn dc) { if (nativeType != null) { Function cast = ConvertModifier.createConvertFunction(getLanguageFactory(), dc.getExpression(), nativeType); cast.setName("cast"); //$NON-NLS-1$ dc.setExpression(cast); } else { dc.setExpression(ConvertModifier.createConvertFunction(getLanguageFactory(), dc.getExpression(), TypeFacility.getDataTypeName(dc.getExpression().getType()))); } }
@Override public void visit(SetQuery obj) { for (int i = 0; i < obj.getColumnNames().length; i++) { DerivedColumn leftDerivedColumn = obj.getLeftQuery().getProjectedQuery().getDerivedColumns().get(i); boolean left_i18n = OracleExecutionFactory.this.isNonAscii(leftDerivedColumn.getExpression()); DerivedColumn rightDerivedColumn = obj.getRightQuery().getProjectedQuery().getDerivedColumns().get(i); boolean right_i18n = OracleExecutionFactory.this.isNonAscii(rightDerivedColumn.getExpression()); if (left_i18n ^ right_i18n) { if (!left_i18n) { leftDerivedColumn.setExpression(toNChar(leftDerivedColumn.getExpression())); } else if (!right_i18n) { rightDerivedColumn.setExpression(toNChar(rightDerivedColumn.getExpression())); } } } super.visit(obj); }
if ((dc.getExpression() instanceof Function) && (((Function)dc.getExpression()).getName().equalsIgnoreCase(SQLConstants.Reserved.CONVERT))) { dc.setExpression(((Function)dc.getExpression()).getParameters().get(0));
obj.setExpression(postgreSQLExecutionFactory.getLanguageFactory().createFunction("cast", //$NON-NLS-1$ new Expression[] {obj.getExpression(), postgreSQLExecutionFactory.getLanguageFactory().createLiteral(castType, TypeFacility.RUNTIME_TYPES.STRING)}, TypeFacility.RUNTIME_TYPES.STRING)); && nativeType != null && nativeType.equalsIgnoreCase(PostgreSQLExecutionFactory.UUID_TYPE)) { obj.setExpression(postgreSQLExecutionFactory.getLanguageFactory().createFunction("cast", //$NON-NLS-1$ new Expression[] {obj.getExpression(), postgreSQLExecutionFactory.getLanguageFactory().createLiteral("varchar", TypeFacility.RUNTIME_TYPES.STRING)}, //$NON-NLS-1$ TypeFacility.RUNTIME_TYPES.STRING));
@Override public List<?> translate(LanguageObject obj, ExecutionContext context) { //DB2 doesn't support cross join convertCrossJoinToInner(obj, getLanguageFactory()); //DB2 needs projected nulls wrapped in casts if (obj instanceof DerivedColumn) { DerivedColumn selectSymbol = (DerivedColumn)obj; if (selectSymbol.getExpression() instanceof Literal) { Literal literal = (Literal)selectSymbol.getExpression(); if (literal.getValue() == null) { String type = TypeFacility.RUNTIME_NAMES.INTEGER; if (literal.getType() != TypeFacility.RUNTIME_TYPES.NULL) { type = TypeFacility.getDataTypeName(literal.getType()); } selectSymbol.setExpression(ConvertModifier.createConvertFunction(getLanguageFactory(), literal, type)); } } } return super.translate(obj, context); }
Expression expr = dc.getExpression(); if (expr.getType() == TypeFacility.RUNTIME_TYPES.GEOMETRY) { dc.setExpression(translateGeometrySelect(expr)); } else if (expr.getType() == TypeFacility.RUNTIME_TYPES.GEOGRAPHY) { dc.setExpression(translateGeographySelect(expr));