Fix HANA test failures on CI

This commit is contained in:
Christian Beikov 2023-01-04 18:02:22 +01:00
parent fc57bd6a17
commit 9080a387fa
3 changed files with 21 additions and 7 deletions

View File

@ -397,6 +397,7 @@ public abstract class AbstractHANADialect extends Dialect {
functionFactory.cosh(); functionFactory.cosh();
functionFactory.sinh(); functionFactory.sinh();
functionFactory.tanh(); functionFactory.tanh();
functionFactory.trunc_roundMode();
functionFactory.log10_log(); functionFactory.log10_log();
functionFactory.log(); functionFactory.log();
functionFactory.bitand(); functionFactory.bitand();

View File

@ -362,6 +362,20 @@ public class CommonFunctionFactory {
.register(); .register();
} }
/**
* SAP HANA
*/
public void trunc_roundMode() {
functionRegistry.registerUnaryBinaryPattern(
"trunc",
"round(?1,0,round_down)",
"round(?1,?2,round_down)",
NUMERIC, INTEGER,
typeConfiguration
).setArgumentListSignature( "(NUMERIC number[, INTEGER places])" );
functionRegistry.registerAlternateKey( "truncate", "trunc" );
}
/** /**
* Returns double between 0.0 and 1.0. First call may specify a seed value. * Returns double between 0.0 and 1.0. First call may specify a seed value.
*/ */

View File

@ -101,8 +101,7 @@ public class HANASchemaMigrationTargetScriptCreationTest extends BaseCoreFunctio
public void testTargetScriptIsCreatedStringTypeDefault() throws Exception { public void testTargetScriptIsCreatedStringTypeDefault() throws Exception {
this.rebuildSessionFactory(); this.rebuildSessionFactory();
String fileContent = new String( Files.readAllBytes( this.output.toPath() ) ); String fileContent = new String( Files.readAllBytes( this.output.toPath() ) );
Pattern fileContentPattern = Pattern Pattern fileContentPattern = Pattern.compile( "create( (column|row))? table test_entity \\(b boolean[^,]+, c " + this.varcharType + "[^,]+, field " + this.varcharType + "[^,]+, lob " + this.clobType );
.compile( "create( (column|row))? table test_entity \\(field " + this.varcharType + ".+, b boolean.+, c " + this.varcharType + ".+, lob " + this.clobType + ".+" );
Matcher fileContentMatcher = fileContentPattern.matcher( fileContent.toLowerCase() ); Matcher fileContentMatcher = fileContentPattern.matcher( fileContent.toLowerCase() );
assertThat( assertThat(
"Script file : " + fileContent.toLowerCase(), "Script file : " + fileContent.toLowerCase(),
@ -117,7 +116,7 @@ public class HANASchemaMigrationTargetScriptCreationTest extends BaseCoreFunctio
config.setProperty( "hibernate.dialect.hana.use_unicode_string_types", "true" ); config.setProperty( "hibernate.dialect.hana.use_unicode_string_types", "true" );
} ); } );
String fileContent = new String( Files.readAllBytes( this.output.toPath() ) ); String fileContent = new String( Files.readAllBytes( this.output.toPath() ) );
Pattern fileContentPattern = Pattern.compile( "create( (column|row))? table test_entity \\(field nvarchar.+, b boolean.+, c nvarchar.+, lob nclob" ); Pattern fileContentPattern = Pattern.compile( "create( (column|row))? table test_entity \\(b boolean[^,]+, c nvarchar[^,]+, field nvarchar[^,]+, lob nclob" );
Matcher fileContentMatcher = fileContentPattern.matcher( fileContent.toLowerCase() ); Matcher fileContentMatcher = fileContentPattern.matcher( fileContent.toLowerCase() );
assertThat( assertThat(
"Script file : " + fileContent.toLowerCase(), "Script file : " + fileContent.toLowerCase(),
@ -132,7 +131,7 @@ public class HANASchemaMigrationTargetScriptCreationTest extends BaseCoreFunctio
config.setProperty( "hibernate.dialect.hana.use_unicode_string_types", "false" ); config.setProperty( "hibernate.dialect.hana.use_unicode_string_types", "false" );
} ); } );
String fileContent = new String( Files.readAllBytes( this.output.toPath() ) ); String fileContent = new String( Files.readAllBytes( this.output.toPath() ) );
Pattern fileContentPattern = Pattern.compile( "create( (column|row))? table test_entity \\(field " + this.varcharType + ".+, b boolean.+, c " + this.varcharType + ".+, lob " + this.clobType ); Pattern fileContentPattern = Pattern.compile( "create( (column|row))? table test_entity \\(b boolean[^,]+, c " + this.varcharType + "[^,]+, field " + this.varcharType + "[^,]+, lob " + this.clobType );
Matcher fileContentMatcher = fileContentPattern.matcher( fileContent.toLowerCase() ); Matcher fileContentMatcher = fileContentPattern.matcher( fileContent.toLowerCase() );
assertThat( assertThat(
"Script file : " + fileContent.toLowerCase(), "Script file : " + fileContent.toLowerCase(),
@ -145,7 +144,7 @@ public class HANASchemaMigrationTargetScriptCreationTest extends BaseCoreFunctio
public void testTargetScriptIsCreatedBooleanTypeDefault() throws Exception { public void testTargetScriptIsCreatedBooleanTypeDefault() throws Exception {
this.rebuildSessionFactory(); this.rebuildSessionFactory();
String fileContent = new String( Files.readAllBytes( this.output.toPath() ) ); String fileContent = new String( Files.readAllBytes( this.output.toPath() ) );
Pattern fileContentPattern = Pattern.compile( "create( (column|row))? table test_entity \\(field " + this.varcharType + ".+, b boolean.+, c " + this.varcharType + ".+, lob " + this.clobType ); Pattern fileContentPattern = Pattern.compile( "create( (column|row))? table test_entity \\(b boolean[^,]+, c " + this.varcharType + "[^,]+, field " + this.varcharType + "[^,]+, lob " + this.clobType );
Matcher fileContentMatcher = fileContentPattern.matcher( fileContent.toLowerCase() ); Matcher fileContentMatcher = fileContentPattern.matcher( fileContent.toLowerCase() );
assertThat( assertThat(
"Script file : " + fileContent.toLowerCase(), "Script file : " + fileContent.toLowerCase(),
@ -160,7 +159,7 @@ public class HANASchemaMigrationTargetScriptCreationTest extends BaseCoreFunctio
config.setProperty( "hibernate.dialect.hana.use_legacy_boolean_type", "true" ); config.setProperty( "hibernate.dialect.hana.use_legacy_boolean_type", "true" );
} ); } );
String fileContent = new String( Files.readAllBytes( this.output.toPath() ) ); String fileContent = new String( Files.readAllBytes( this.output.toPath() ) );
Pattern fileContentPattern = Pattern.compile( "create( (column|row))? table test_entity \\(field " + this.varcharType + ".+, b tinyint.+, c " + this.varcharType + ".+, lob " + this.clobType ); Pattern fileContentPattern = Pattern.compile( "create( (column|row))? table test_entity \\(b tinyint[^,]+, c " + this.varcharType + "[^,]+, field " + this.varcharType + "[^,]+, lob " + this.clobType );
Matcher fileContentMatcher = fileContentPattern.matcher( fileContent.toLowerCase() ); Matcher fileContentMatcher = fileContentPattern.matcher( fileContent.toLowerCase() );
assertThat( assertThat(
"Script file : " + fileContent.toLowerCase(), "Script file : " + fileContent.toLowerCase(),
@ -175,7 +174,7 @@ public class HANASchemaMigrationTargetScriptCreationTest extends BaseCoreFunctio
config.setProperty( "hibernate.dialect.hana.use_legacy_boolean_type", "false" ); config.setProperty( "hibernate.dialect.hana.use_legacy_boolean_type", "false" );
} ); } );
String fileContent = new String( Files.readAllBytes( this.output.toPath() ) ); String fileContent = new String( Files.readAllBytes( this.output.toPath() ) );
Pattern fileContentPattern = Pattern.compile( "create( (column|row))? table test_entity \\(field " + this.varcharType + ".+, b boolean.+, c " + this.varcharType + ".+, lob " + this.clobType ); Pattern fileContentPattern = Pattern.compile( "create( (column|row))? table test_entity \\(b boolean[^,]+, c " + this.varcharType + "[^,]+, field " + this.varcharType + "[^,]+, lob " + this.clobType );
Matcher fileContentMatcher = fileContentPattern.matcher( fileContent.toLowerCase() ); Matcher fileContentMatcher = fileContentPattern.matcher( fileContent.toLowerCase() );
assertThat( assertThat(
"Script file : " + fileContent.toLowerCase(), "Script file : " + fileContent.toLowerCase(),