HHH-16528 Revert SybaseDialect NameQualifierSupport to CATALOG only and fix ansinull option for jconnect

This commit is contained in:
Christian Beikov 2023-04-28 08:57:39 +02:00
parent f998bc80b5
commit db3c73f302
6 changed files with 40 additions and 35 deletions

View File

@ -88,8 +88,8 @@ ext {
'jdbc.user' : 'hibernate_orm_test',
'jdbc.pass' : 'hibernate_orm_test',
// Disable prepared statement caching to avoid issues with changing schemas
'jdbc.url' : 'jdbc:sybase:Tds:' + dbHost + ':5000/hibernate_orm_test?SQLINITSTRING=set quoted_identifier on&SQLINITSTRING=set ANSINULL on',
'connection.init_sql' : ''
'jdbc.url' : 'jdbc:sybase:Tds:' + dbHost + ':5000/hibernate_orm_test',
'connection.init_sql' : 'set ansinull on set quoted_identifier on'
],
mysql : [
'db.dialect' : 'org.hibernate.dialect.MySQLDialect',

View File

@ -54,10 +54,11 @@ import org.hibernate.sql.ast.tree.Statement;
import org.hibernate.sql.ast.tree.select.SelectStatement;
import org.hibernate.sql.exec.spi.JdbcOperation;
import org.hibernate.type.JavaObjectType;
import org.hibernate.type.NullType;
import org.hibernate.type.descriptor.jdbc.BlobJdbcType;
import org.hibernate.type.descriptor.jdbc.ClobJdbcType;
import org.hibernate.type.descriptor.jdbc.JdbcType;
import org.hibernate.type.descriptor.jdbc.ObjectNullAsNullTypeJdbcType;
import org.hibernate.type.descriptor.jdbc.ObjectNullAsBinaryTypeJdbcType;
import org.hibernate.type.descriptor.jdbc.TinyIntAsSmallIntJdbcType;
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
@ -191,12 +192,20 @@ public class SybaseLegacyDialect extends AbstractTransactSQLDialect {
jdbcTypeRegistry.addDescriptor( Types.BLOB, BlobJdbcType.PRIMITIVE_ARRAY_BINDING );
// Sybase requires a custom binder for binding untyped nulls with the NULL type
typeContributions.contributeJdbcType( ObjectNullAsNullTypeJdbcType.INSTANCE );
typeContributions.contributeJdbcType( ObjectNullAsBinaryTypeJdbcType.INSTANCE );
// Until we remove StandardBasicTypes, we have to keep this
typeContributions.contributeType(
new JavaObjectType(
ObjectNullAsNullTypeJdbcType.INSTANCE,
ObjectNullAsBinaryTypeJdbcType.INSTANCE,
typeContributions.getTypeConfiguration()
.getJavaTypeRegistry()
.getDescriptor( Object.class )
)
);
typeContributions.contributeType(
new NullType(
ObjectNullAsBinaryTypeJdbcType.INSTANCE,
typeContributions.getTypeConfiguration()
.getJavaTypeRegistry()
.getDescriptor( Object.class )
@ -356,9 +365,8 @@ public class SybaseLegacyDialect extends AbstractTransactSQLDialect {
@Override
public NameQualifierSupport getNameQualifierSupport() {
if ( getVersion().isSameOrAfter( 15 ) ) {
return NameQualifierSupport.BOTH;
}
// No support for schemas: https://userapps.support.sap.com/sap/support/knowledge/en/2591730
// Authorization schemas seem to be something different: https://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc36272.1550/html/commands/X48762.htm
return NameQualifierSupport.CATALOG;
}

View File

@ -53,6 +53,7 @@ import org.hibernate.sql.ast.tree.Statement;
import org.hibernate.sql.ast.tree.select.SelectStatement;
import org.hibernate.sql.exec.spi.JdbcOperation;
import org.hibernate.type.JavaObjectType;
import org.hibernate.type.NullType;
import org.hibernate.type.descriptor.jdbc.BlobJdbcType;
import org.hibernate.type.descriptor.jdbc.ClobJdbcType;
import org.hibernate.type.descriptor.jdbc.JdbcType;
@ -220,6 +221,14 @@ public class SybaseDialect extends AbstractTransactSQLDialect {
.getDescriptor( Object.class )
)
);
typeContributions.contributeType(
new NullType(
ObjectNullAsBinaryTypeJdbcType.INSTANCE,
typeContributions.getTypeConfiguration()
.getJavaTypeRegistry()
.getDescriptor( Object.class )
)
);
}
@Override
@ -380,12 +389,9 @@ public class SybaseDialect extends AbstractTransactSQLDialect {
@Override
public NameQualifierSupport getNameQualifierSupport() {
if ( driverKind == SybaseDriverKind.JTDS ) {
return NameQualifierSupport.CATALOG;
}
else {
return NameQualifierSupport.BOTH;
}
// No support for schemas: https://userapps.support.sap.com/sap/support/knowledge/en/2591730
// Authorization schemas seem to be something different: https://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc36272.1550/html/commands/X48762.htm
return NameQualifierSupport.CATALOG;
}
@Override

View File

@ -15,23 +15,23 @@ import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.boot.spi.MetadataImplementor;
import org.hibernate.cfg.Environment;
import org.hibernate.dialect.DatabaseVersion;
import org.hibernate.dialect.Dialect;
import org.hibernate.tool.hbm2ddl.SchemaUpdate;
import org.hibernate.tool.schema.TargetType;
import org.junit.Test;
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
import org.hibernate.testing.orm.junit.JiraKey;
import org.hibernate.testing.orm.junit.RequiresDialectFeature;
import org.hibernate.testing.TestForIssue;
import org.junit.jupiter.api.Test;
import static org.hamcrest.core.Is.is;
import static org.hibernate.dialect.SimpleDatabaseVersion.ZERO_VERSION;
import static org.junit.Assert.assertThat;
/**
* @author Andrea Boriero
*/
@TestForIssue(jiraKey = "HHH-10635")
@JiraKey("HHH-10635")
@RequiresDialectFeature(feature = DialectFeatureChecks.SupportsCommentOn.class)
public class CommentGenerationTest {
@Test
@ -39,7 +39,6 @@ public class CommentGenerationTest {
final String resource = "org/hibernate/orm/test/schemaupdate/CommentGeneration.hbm.xml";
StandardServiceRegistry ssr = new StandardServiceRegistryBuilder()
.applySetting( Environment.HBM2DDL_AUTO, "none" )
.applySetting( Environment.DIALECT, SupportCommentDialect.class.getName() )
.build();
try {
File output = File.createTempFile( "update_script", ".sql" );
@ -65,16 +64,4 @@ public class CommentGenerationTest {
StandardServiceRegistryBuilder.destroy( ssr );
}
}
public static class SupportCommentDialect extends Dialect{
@Override
public boolean supportsCommentOn() {
return true;
}
@Override
public DatabaseVersion getVersion() {
return ZERO_VERSION;
}
}
}

View File

@ -39,7 +39,6 @@ import org.hibernate.testing.RequiresDialect;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.jta.TestingJtaBootstrap;
import org.hibernate.testing.junit4.BaseUnitTestCase;
import org.hibernate.orm.test.schemaupdate.CommentGenerationTest;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@ -67,7 +66,6 @@ public class StatementsWithoutTerminalCharsImportFileTest extends BaseUnitTestCa
// NOTE : the
ssr = new StandardServiceRegistryBuilder()
.applySetting( Environment.HBM2DDL_AUTO, "none" )
.applySetting( Environment.DIALECT, CommentGenerationTest.SupportCommentDialect.class.getName() )
.applySetting(
Environment.HBM2DDL_IMPORT_FILES,
"/org/hibernate/orm/test/tool/schema/scripts/statements-without-terminal-chars.sql"

View File

@ -658,4 +658,10 @@ abstract public class DialectFeatureChecks {
return dialect instanceof SybaseDialect && ( (SybaseDialect) dialect ).getDriverKind() == SybaseDriverKind.JTDS;
}
}
public static class SupportsCommentOn implements DialectFeatureCheck {
public boolean apply(Dialect dialect) {
return dialect.supportsCommentOn();
}
}
}