mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-18 09:05:21 +00:00
HHH-16945 Cast to varbinary for tuple distinct count on SQL Server to avoid collation issues
This commit is contained in:
parent
a145db8d9b
commit
ce19d9600e
@ -300,7 +300,8 @@ public void initializeFunctionRegistry(FunctionContributions functionContributio
|
|||||||
"count_big",
|
"count_big",
|
||||||
"+",
|
"+",
|
||||||
"varchar(max)",
|
"varchar(max)",
|
||||||
false
|
false,
|
||||||
|
"varbinary(max)"
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -314,7 +314,8 @@ public void initializeFunctionRegistry(FunctionContributions functionContributio
|
|||||||
"count_big",
|
"count_big",
|
||||||
"+",
|
"+",
|
||||||
"varchar(max)",
|
"varchar(max)",
|
||||||
false
|
true,
|
||||||
|
"varbinary(max)"
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -49,6 +49,7 @@ public class CountFunction extends AbstractSqmSelfRenderingFunctionDescriptor {
|
|||||||
private final String concatOperator;
|
private final String concatOperator;
|
||||||
private final String concatArgumentCastType;
|
private final String concatArgumentCastType;
|
||||||
private final boolean castDistinctStringConcat;
|
private final boolean castDistinctStringConcat;
|
||||||
|
private final String distinctArgumentCastType;
|
||||||
|
|
||||||
public CountFunction(
|
public CountFunction(
|
||||||
Dialect dialect,
|
Dialect dialect,
|
||||||
@ -79,7 +80,8 @@ public CountFunction(
|
|||||||
"count",
|
"count",
|
||||||
concatOperator,
|
concatOperator,
|
||||||
concatArgumentCastType,
|
concatArgumentCastType,
|
||||||
castDistinctStringConcat
|
castDistinctStringConcat,
|
||||||
|
concatArgumentCastType
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,6 +93,27 @@ public CountFunction(
|
|||||||
String concatOperator,
|
String concatOperator,
|
||||||
String concatArgumentCastType,
|
String concatArgumentCastType,
|
||||||
boolean castDistinctStringConcat) {
|
boolean castDistinctStringConcat) {
|
||||||
|
this(
|
||||||
|
dialect,
|
||||||
|
typeConfiguration,
|
||||||
|
defaultArgumentRenderingMode,
|
||||||
|
countFunctionName,
|
||||||
|
concatOperator,
|
||||||
|
concatArgumentCastType,
|
||||||
|
castDistinctStringConcat,
|
||||||
|
concatArgumentCastType
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CountFunction(
|
||||||
|
Dialect dialect,
|
||||||
|
TypeConfiguration typeConfiguration,
|
||||||
|
SqlAstNodeRenderingMode defaultArgumentRenderingMode,
|
||||||
|
String countFunctionName,
|
||||||
|
String concatOperator,
|
||||||
|
String concatArgumentCastType,
|
||||||
|
boolean castDistinctStringConcat,
|
||||||
|
String distinctArgumentCastType) {
|
||||||
super(
|
super(
|
||||||
"count",
|
"count",
|
||||||
FunctionKind.AGGREGATE,
|
FunctionKind.AGGREGATE,
|
||||||
@ -106,6 +129,7 @@ public CountFunction(
|
|||||||
this.concatOperator = concatOperator;
|
this.concatOperator = concatOperator;
|
||||||
this.concatArgumentCastType = concatArgumentCastType;
|
this.concatArgumentCastType = concatArgumentCastType;
|
||||||
this.castDistinctStringConcat = castDistinctStringConcat;
|
this.castDistinctStringConcat = castDistinctStringConcat;
|
||||||
|
this.distinctArgumentCastType = distinctArgumentCastType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -211,7 +235,7 @@ else if ( !dialect.supportsTupleDistinctCounts() ) {
|
|||||||
sqlAppender.appendSql( "')" );
|
sqlAppender.appendSql( "')" );
|
||||||
if ( castDistinctStringConcat ) {
|
if ( castDistinctStringConcat ) {
|
||||||
sqlAppender.appendSql( " as " );
|
sqlAppender.appendSql( " as " );
|
||||||
sqlAppender.appendSql( concatArgumentCastType );
|
sqlAppender.appendSql( distinctArgumentCastType );
|
||||||
sqlAppender.appendSql( ')' );
|
sqlAppender.appendSql( ')' );
|
||||||
}
|
}
|
||||||
if ( caseWrapper ) {
|
if ( caseWrapper ) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user