Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -393,20 +393,26 @@ public String castPattern(CastType from, CastType to) {
}
break;
case INTEGER_BOOLEAN:
result = BooleanDecoder.toIntegerBoolean( from );
result = from == CastType.STRING
? buildStringToBooleanCastDecode( "1", "0" )
: BooleanDecoder.toIntegerBoolean( from );
if ( result != null ) {
return result;
}
break;
case YN_BOOLEAN:
result = BooleanDecoder.toYesNoBoolean( from );
result = from == CastType.STRING
? buildStringToBooleanCastDecode( "'Y'", "'N'" )
: BooleanDecoder.toYesNoBoolean( from );
if ( result != null ) {
return result;
}
break;
case BOOLEAN:
case TF_BOOLEAN:
result = BooleanDecoder.toTrueFalseBoolean( from );
result = from == CastType.STRING
? buildStringToBooleanCastDecode( "'T'", "'F'" )
: BooleanDecoder.toTrueFalseBoolean( from );
if ( result != null ) {
return result;
}
Expand Down Expand Up @@ -702,4 +708,14 @@ public SQLExceptionConversionDelegate buildSQLExceptionConversionDelegate() {
};
}

@Override
public String getDual() {
return "dual";
}

@Override
public String getFromDualForSelectOnly() {
return " from " + getDual();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -218,16 +218,6 @@ public void visitQueryPartTableReference(QueryPartTableReference tableReference)
emulateQueryPartTableReferenceColumnAliasing( tableReference );
}

@Override
protected String getDual() {
return "dual";
}

@Override
protected String getFromDualForSelectOnly() {
return " from " + getDual();
}

@Override
protected boolean needsRecursiveKeywordInWithClause() {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -515,4 +515,16 @@ private void timediff(
sqlAppender.append( diffUnit.conversionFactor( toUnit, this ) );
}

@Override
public String getDual() {
//TODO: is this really needed?
//TODO: would "from table({0})" be better?
return "db_root";
}

@Override
public String getFromDualForSelectOnly() {
return " from " + getDual();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,4 @@ protected boolean supportsRowValueConstructorSyntaxInInList() {
protected boolean supportsRowValueConstructorSyntaxInQuantifiedPredicates() {
return false;
}

@Override
protected String getDual() {
//TODO: is this really needed?
//TODO: would "from table({0})" be better?
return "db_root";
}

@Override
protected String getFromDualForSelectOnly() {
return " from " + getDual();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
import org.hibernate.procedure.internal.DB2CallableStatementSupport;
import org.hibernate.procedure.spi.CallableStatementSupport;
import org.hibernate.query.sqm.CastType;
import org.hibernate.query.sqm.IntervalType;
import org.hibernate.query.sqm.TemporalUnit;
import org.hibernate.query.sqm.mutation.internal.cte.CteInsertStrategy;
Expand Down Expand Up @@ -1134,6 +1135,16 @@ public String extractPattern(TemporalUnit unit) {
return super.extractPattern( unit );
}

@Override
public String castPattern(CastType from, CastType to) {
if ( from == CastType.STRING && to == CastType.BOOLEAN ) {
return "cast(?1 as ?2)";
}
else {
return super.castPattern( from, to );
}
}

@Override
public int getInExpressionCountLimit() {
return BIND_PARAMETERS_NUMBER_LIMIT;
Expand Down Expand Up @@ -1201,4 +1212,14 @@ public DmlTargetColumnQualifierSupport getDmlTargetColumnQualifierSupport() {
public boolean supportsFromClauseInUpdate() {
return getDB2Version().isSameOrAfter( 11 );
}

@Override
public String getDual() {
return "sysibm.dual";
}

@Override
public String getFromDualForSelectOnly() {
return " from " + getDual();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -604,16 +604,6 @@ protected boolean supportsRowValueConstructorSyntaxInQuantifiedPredicates() {
return false;
}

@Override
protected String getDual() {
return "sysibm.dual";
}

@Override
protected String getFromDualForSelectOnly() {
return " from " + getDual();
}

@Override
protected void visitReturningColumns(List<ColumnReference> returningColumns) {
// For DB2 we use #renderReturningClause to render a wrapper around the DML statement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1040,6 +1040,11 @@ public boolean supportsWindowFunctions() {
return true;
}

@Override
public boolean supportsValuesList() {
return true;
}

@Override
public IdentifierHelper buildIdentifierHelper(IdentifierHelperBuilder builder, DatabaseMetaData dbMetaData)
throws SQLException {
Expand All @@ -1057,4 +1062,14 @@ public DmlTargetColumnQualifierSupport getDmlTargetColumnQualifierSupport() {
return DmlTargetColumnQualifierSupport.TABLE_ALIAS;
}

@Override
public String getDual() {
return "(values 0)";
}

@Override
public String getFromDualForSelectOnly() {
return " from " + getDual() + " dual";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -1051,6 +1051,11 @@ public boolean supportsWindowFunctions() {
return getVersion().isSameOrAfter( 10, 4 );
}

@Override
public boolean supportsValuesList() {
return true;
}

@Override
public IdentifierHelper buildIdentifierHelper(IdentifierHelperBuilder builder, DatabaseMetaData dbMetaData)
throws SQLException {
Expand All @@ -1062,4 +1067,14 @@ public IdentifierHelper buildIdentifierHelper(IdentifierHelperBuilder builder, D
public DmlTargetColumnQualifierSupport getDmlTargetColumnQualifierSupport() {
return DmlTargetColumnQualifierSupport.TABLE_ALIAS;
}

@Override
public String getDual() {
return "(values 0)";
}

@Override
public String getFromDualForSelectOnly() {
return " from " + getDual() + " dual";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -298,16 +298,6 @@ protected boolean supportsRowValueConstructorSyntaxInQuantifiedPredicates() {
return false;
}

@Override
protected String getDual() {
return "(values 0)";
}

@Override
protected String getFromDualForSelectOnly() {
return " from " + getDual() + " dual";
}

@Override
protected boolean needsRowsToSkip() {
return !supportsOffsetFetchClause();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,16 +298,6 @@ protected boolean supportsRowValueConstructorSyntaxInQuantifiedPredicates() {
return false;
}

@Override
protected String getDual() {
return "(values 0)";
}

@Override
protected String getFromDualForSelectOnly() {
return " from " + getDual() + " dual";
}

@Override
protected boolean needsRowsToSkip() {
return !supportsOffsetFetchClause();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,25 +401,33 @@ public String castPattern(CastType from, CastType to) {
}
break;
case BOOLEAN:
result = BooleanDecoder.toBoolean( from );
result = from == CastType.STRING
? buildStringToBooleanCastDecode( "true", "false" )
: BooleanDecoder.toBoolean( from );
if ( result != null ) {
return result;
}
break;
case INTEGER_BOOLEAN:
result = BooleanDecoder.toIntegerBoolean( from );
result = from == CastType.STRING
? buildStringToBooleanCastDecode( "1", "0" )
: BooleanDecoder.toIntegerBoolean( from );
if ( result != null ) {
return result;
}
break;
case YN_BOOLEAN:
result = BooleanDecoder.toYesNoBoolean( from );
result = from == CastType.STRING
? buildStringToBooleanCastDecode( "'Y'", "'N'" )
: BooleanDecoder.toYesNoBoolean( from );
if ( result != null ) {
return result;
}
break;
case TF_BOOLEAN:
result = BooleanDecoder.toTrueFalseBoolean( from );
result = from == CastType.STRING
? buildStringToBooleanCastDecode( "'T'", "'F'" )
: BooleanDecoder.toTrueFalseBoolean( from );
if ( result != null ) {
return result;
}
Expand Down Expand Up @@ -1094,4 +1102,14 @@ else if ( supportsOffset && temporalAccessor instanceof Instant ) {
}

}

@Override
public String getDual() {
return "rdb$database";
}

@Override
public String getFromDualForSelectOnly() {
return " from " + getDual();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -260,16 +260,6 @@ protected boolean supportsRowValueConstructorSyntaxInQuantifiedPredicates() {
return false;
}

@Override
protected String getDual() {
return "rdb$database";
}

@Override
protected String getFromDualForSelectOnly() {
return " from " + getDual();
}

private boolean supportsOffsetFetchClause() {
return getDialect().getVersion().isSameOrAfter( 3 );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import org.hibernate.internal.util.StringHelper;
import org.hibernate.metamodel.mapping.EntityMappingType;
import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
import org.hibernate.query.sqm.CastType;
import org.hibernate.query.sqm.FetchClauseType;
import org.hibernate.query.sqm.IntervalType;
import org.hibernate.dialect.NullOrdering;
Expand Down Expand Up @@ -513,6 +514,16 @@ public String extractPattern(TemporalUnit unit) {
: super.extractPattern(unit);
}

@Override
public String castPattern(CastType from, CastType to) {
if ( from == CastType.STRING && to == CastType.BOOLEAN ) {
return "cast(?1 as ?2)";
}
else {
return super.castPattern( from, to );
}
}

@Override
public String timestampaddPattern(TemporalUnit unit, TemporalType temporalType, IntervalType intervalType) {
if ( intervalType != null ) {
Expand Down Expand Up @@ -991,4 +1002,14 @@ public String getCaseInsensitiveLike() {
public boolean supportsCaseInsensitiveLike() {
return getVersion().isSameOrAfter( 1, 4, 194 );
}

@Override
public boolean supportsValuesList() {
return true;
}

@Override
public String getDual() {
return "dual";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -386,11 +386,6 @@ protected boolean supportsNullPrecedence() {
return getClauseStack().getCurrent() != Clause.WITHIN_GROUP || getDialect().getVersion().isSameOrAfter( 2 );
}

@Override
protected String getDual() {
return "dual";
}

private boolean supportsOffsetFetchClause() {
return getDialect().getVersion().isSameOrAfter( 1, 4, 195 );
}
Expand Down
Loading
Loading