-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test is very "synthetic", and instantiating Hibernate internal classes is not portable as they might change in future versions. A good test reproduces a "real-world" scenario, the one where you experienced this particular bug, ensuring that no regressions are introduced. Could you try to isolate that in a simple reproducer? Thanks. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hello @mbellade, I tried to create instances of Hibernate internal class which were not portable. But, tableInformation is null for table PERSON_TABLE. I have supposed that is existing in database. Could I send codes for your review to understand the problem? Thanks. ![]() There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hey @mehmetali2003, I'm not really sure what you mean by your message and what I should look at in this code screenshot. Feel free to send any code for our review and we'll try to help. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hello @mbellade, Thanks for your feedback. I have send a new commit. Can you check, please? |
||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much better, let's apply Hibernate's code style: