Skip to content

HHH-14270 GroupedSchemaValidatorImpl / NameSpaceTablesInformation does not find different-case table information in case insensitive environment #10429

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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 @@ -22,7 +22,7 @@ public NameSpaceTablesInformation(IdentifierHelper identifierHelper) {
}

public void addTableInformation(TableInformation tableInformation) {
tables.put( tableInformation.getName().getTableName().getText(), tableInformation );
tables.put(identifierHelper.toMetaDataObjectName( tableInformation.getName().getTableName()), tableInformation);
}

public TableInformation getTableInformation(Table table) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* SPDX-License-Identifier: Apache-2.0
* Copyright Red Hat Inc. and Hibernate Authors
*/
package org.hibernate.tool.schema.extract.spi;

import org.hibernate.boot.model.relational.QualifiedTableName;
import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.mapping.Table;
import org.hibernate.testing.orm.junit.JiraKey;
import org.hibernate.testing.util.ServiceRegistryUtil;
import org.junit.Assert;
import org.junit.jupiter.api.Test;
import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
import org.hibernate.engine.jdbc.env.spi.IdentifierHelper;
import org.hibernate.tool.schema.extract.internal.TableInformationImpl;
import org.hibernate.boot.model.relational.Namespace.Name;
import org.hibernate.boot.model.naming.Identifier;
import org.mockito.Mockito;


public class NameSpaceTablesInformationTest {

@Test
@JiraKey(value = "HHH-14270")
public void testNameSpaceTablesInformation() {
StandardServiceRegistry ssr = ServiceRegistryUtil.serviceRegistry();
JdbcEnvironment jdbcEnvironment = ssr.getService( JdbcEnvironment.class );
IdentifierHelper identifierHelper = jdbcEnvironment.getIdentifierHelper();

NameSpaceTablesInformation nameSpaceTablesInformation = new NameSpaceTablesInformation(identifierHelper);
Name schemaName = new Name( new Identifier( "-", false ), new Identifier( "-", false ) );
InformationExtractor informationExtractor = Mockito.mock( InformationExtractor.class );
QualifiedTableName tableName = new QualifiedTableName( schemaName, new Identifier( "-", false ) );

TableInformation tableInformation = new TableInformationImpl( informationExtractor, identifierHelper, tableName, false, null );
nameSpaceTablesInformation.addTableInformation( tableInformation );
final Table table = new Table( "orm", tableName.getTableName().getText() );
nameSpaceTablesInformation.getTableInformation( table );
boolean tableMatched = tableInformation.getName().getTableName().getText().equals( tableName.getTableName().getText() );
Assert.assertTrue("Table matched: ", tableMatched);
}
}