HHH-14251 Fix issue for Dialects not supporting row value constructor Syntax
This commit is contained in:
parent
ec7a278358
commit
54ea3c15bf
|
@ -111,20 +111,21 @@ public class BinaryLogicOperatorNode extends AbstractSelectExpression implements
|
||||||
// mutation depends on the types of nodes involved...
|
// mutation depends on the types of nodes involved...
|
||||||
int comparisonType = getType();
|
int comparisonType = getType();
|
||||||
String comparisonText = getText();
|
String comparisonText = getText();
|
||||||
|
if ( !isInsideSetClause() ) {
|
||||||
|
switch ( comparisonType ) {
|
||||||
|
case HqlSqlTokenTypes.EQ:
|
||||||
|
setType( HqlSqlTokenTypes.AND );
|
||||||
|
setText( "AND" );
|
||||||
|
break;
|
||||||
|
|
||||||
switch ( comparisonType ) {
|
case HqlSqlTokenTypes.NE:
|
||||||
case HqlSqlTokenTypes.EQ:
|
setType( HqlSqlTokenTypes.OR );
|
||||||
setType( HqlSqlTokenTypes.AND );
|
setText( "OR" );
|
||||||
setText( "AND" );
|
break;
|
||||||
break;
|
|
||||||
|
|
||||||
case HqlSqlTokenTypes.NE:
|
default:
|
||||||
setType( HqlSqlTokenTypes.OR );
|
throw new QuerySyntaxException( comparisonText + " operator not supported on composite types." );
|
||||||
setText( "OR" );
|
}
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
throw new QuerySyntaxException( comparisonText + " operator not supported on composite types." );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] lhsElementTexts = extractMutationTexts( getLeftHandOperand(), valueElements );
|
String[] lhsElementTexts = extractMutationTexts( getLeftHandOperand(), valueElements );
|
||||||
|
@ -153,8 +154,10 @@ public class BinaryLogicOperatorNode extends AbstractSelectExpression implements
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void translate(
|
protected void translate(
|
||||||
int valueElements, int comparisonType,
|
int valueElements,
|
||||||
String comparisonText, String[] lhsElementTexts,
|
int comparisonType,
|
||||||
|
String comparisonText,
|
||||||
|
String[] lhsElementTexts,
|
||||||
String[] rhsElementTexts,
|
String[] rhsElementTexts,
|
||||||
ParameterSpecification lhsEmbeddedCompositeParameterSpecification,
|
ParameterSpecification lhsEmbeddedCompositeParameterSpecification,
|
||||||
ParameterSpecification rhsEmbeddedCompositeParameterSpecification,
|
ParameterSpecification rhsEmbeddedCompositeParameterSpecification,
|
||||||
|
@ -164,14 +167,21 @@ public class BinaryLogicOperatorNode extends AbstractSelectExpression implements
|
||||||
|
|
||||||
for ( int i = valueElements - 1; i > 0; i-- ) {
|
for ( int i = valueElements - 1; i > 0; i-- ) {
|
||||||
if ( i == 1 ) {
|
if ( i == 1 ) {
|
||||||
AST op1 = getASTFactory().create( comparisonType, comparisonText );
|
final AST op1;
|
||||||
|
if ( isInsideSetClause() ) {
|
||||||
|
op1 = container;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
op1 = getASTFactory().create( comparisonType, comparisonText );
|
||||||
|
}
|
||||||
|
|
||||||
SqlFragment lhs1 = (SqlFragment) getASTFactory().create( HqlSqlTokenTypes.SQL_TOKEN, lhsElementTexts[0] );
|
SqlFragment lhs1 = (SqlFragment) getASTFactory().create( HqlSqlTokenTypes.SQL_TOKEN, lhsElementTexts[0] );
|
||||||
SqlFragment rhs1 = (SqlFragment) getASTFactory().create( HqlSqlTokenTypes.SQL_TOKEN, rhsElementTexts[0] );
|
SqlFragment rhs1 = (SqlFragment) getASTFactory().create( HqlSqlTokenTypes.SQL_TOKEN, rhsElementTexts[0] );
|
||||||
copyReferencedTables( leftHandOperand, lhs1 );
|
copyReferencedTables( leftHandOperand, lhs1 );
|
||||||
copyReferencedTables( rightHandOperand, rhs1 );
|
copyReferencedTables( rightHandOperand, rhs1 );
|
||||||
op1.setFirstChild( lhs1 );
|
op1.setFirstChild( lhs1 );
|
||||||
lhs1.setNextSibling( rhs1 );
|
lhs1.setNextSibling( rhs1 );
|
||||||
container.setFirstChild( op1 );
|
|
||||||
AST op2 = getASTFactory().create( comparisonType, comparisonText );
|
AST op2 = getASTFactory().create( comparisonType, comparisonText );
|
||||||
SqlFragment lhs2 = (SqlFragment) getASTFactory().create( HqlSqlTokenTypes.SQL_TOKEN, lhsElementTexts[1] );
|
SqlFragment lhs2 = (SqlFragment) getASTFactory().create( HqlSqlTokenTypes.SQL_TOKEN, lhsElementTexts[1] );
|
||||||
SqlFragment rhs2 = (SqlFragment) getASTFactory().create( HqlSqlTokenTypes.SQL_TOKEN, rhsElementTexts[1] );
|
SqlFragment rhs2 = (SqlFragment) getASTFactory().create( HqlSqlTokenTypes.SQL_TOKEN, rhsElementTexts[1] );
|
||||||
|
@ -181,6 +191,10 @@ public class BinaryLogicOperatorNode extends AbstractSelectExpression implements
|
||||||
lhs2.setNextSibling( rhs2 );
|
lhs2.setNextSibling( rhs2 );
|
||||||
op1.setNextSibling( op2 );
|
op1.setNextSibling( op2 );
|
||||||
|
|
||||||
|
if ( !isInsideSetClause() ) {
|
||||||
|
container.setFirstChild( op1 );
|
||||||
|
}
|
||||||
|
|
||||||
// "pass along" our initial embedded parameter node(s) to the first generated
|
// "pass along" our initial embedded parameter node(s) to the first generated
|
||||||
// sql fragment so that it can be handled later for parameter binding...
|
// sql fragment so that it can be handled later for parameter binding...
|
||||||
if ( lhsEmbeddedCompositeParameterSpecification != null ) {
|
if ( lhsEmbeddedCompositeParameterSpecification != null ) {
|
||||||
|
@ -206,6 +220,10 @@ public class BinaryLogicOperatorNode extends AbstractSelectExpression implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isInsideSetClause() {
|
||||||
|
return getWalker().getCurrentClauseType() == HqlSqlTokenTypes.SET;
|
||||||
|
}
|
||||||
|
|
||||||
private static void copyReferencedTables(Node from, SqlFragment to) {
|
private static void copyReferencedTables(Node from, SqlFragment to) {
|
||||||
if (from instanceof TableReferenceNode) {
|
if (from instanceof TableReferenceNode) {
|
||||||
TableReferenceNode tableReferenceNode = (TableReferenceNode) from;
|
TableReferenceNode tableReferenceNode = (TableReferenceNode) from;
|
||||||
|
|
Loading…
Reference in New Issue