Deprecate JdbcMySqlDialect.INSTANCE and MySqlDialect.MYSQL_IDENTIFIER_PROCESSING.
MySql does not have a fixed Identifierprocessing, therefore predefined instances doesn't make sense. Closes #2060 See https://dev.mysql.com/doc/refman/8.4/en/identifier-case-sensitivity.html
This commit is contained in:
@@ -42,7 +42,17 @@ import org.springframework.lang.NonNull;
|
||||
*/
|
||||
public class JdbcMySqlDialect extends MySqlDialect implements JdbcDialect {
|
||||
|
||||
public static final JdbcMySqlDialect INSTANCE = new JdbcMySqlDialect();
|
||||
/**
|
||||
* Predefined instance of the {@literal JdbcMySqlDialect}.
|
||||
*
|
||||
* @deprecated Use the constructor instead. There is no one correct MySqlDialect, since the behaviour of MySql depends
|
||||
* on various configuration options. See
|
||||
*
|
||||
* <pre>
|
||||
* <a href="https://dev.mysql.com/doc/refman/8.4/en/identifier-case-sensitivity.html">Identifier Case Sensitivity</a>
|
||||
* </pre>
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "4.0") public static final JdbcMySqlDialect INSTANCE = new JdbcMySqlDialect();
|
||||
|
||||
public JdbcMySqlDialect(IdentifierProcessing identifierProcessing) {
|
||||
super(identifierProcessing);
|
||||
|
||||
@@ -35,6 +35,7 @@ import org.springframework.data.relational.core.conversion.MutableAggregateChang
|
||||
import org.springframework.data.relational.core.mapping.RelationalMappingContext;
|
||||
import org.springframework.data.relational.core.mapping.Sequence;
|
||||
import org.springframework.data.relational.core.mapping.Table;
|
||||
import org.springframework.data.relational.core.sql.IdentifierProcessing;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations;
|
||||
import org.springframework.jdbc.core.namedparam.SqlParameterSource;
|
||||
@@ -50,6 +51,8 @@ class IdGeneratingEntityCallbackTest {
|
||||
|
||||
@Mock NamedParameterJdbcOperations operations;
|
||||
RelationalMappingContext relationalMappingContext;
|
||||
private JdbcMySqlDialect mySqlDialect = new JdbcMySqlDialect(
|
||||
IdentifierProcessing.create(new IdentifierProcessing.Quoting("`"), IdentifierProcessing.LetterCasing.LOWER_CASE));
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
@@ -64,8 +67,8 @@ class IdGeneratingEntityCallbackTest {
|
||||
|
||||
NamedParameterJdbcOperations operations = mock(NamedParameterJdbcOperations.class);
|
||||
|
||||
IdGeneratingEntityCallback subject = new IdGeneratingEntityCallback(relationalMappingContext,
|
||||
JdbcMySqlDialect.INSTANCE, operations);
|
||||
IdGeneratingEntityCallback subject = new IdGeneratingEntityCallback(relationalMappingContext, mySqlDialect,
|
||||
operations);
|
||||
|
||||
EntityWithSequence processed = (EntityWithSequence) subject.onBeforeSave(new EntityWithSequence(),
|
||||
MutableAggregateChange.forSave(new EntityWithSequence()));
|
||||
@@ -76,8 +79,8 @@ class IdGeneratingEntityCallbackTest {
|
||||
@Test // GH-1923
|
||||
void entityIsNotMarkedWithTargetSequence() {
|
||||
|
||||
IdGeneratingEntityCallback subject = new IdGeneratingEntityCallback(relationalMappingContext,
|
||||
JdbcMySqlDialect.INSTANCE, operations);
|
||||
IdGeneratingEntityCallback subject = new IdGeneratingEntityCallback(relationalMappingContext, mySqlDialect,
|
||||
operations);
|
||||
|
||||
NoSequenceEntity processed = (NoSequenceEntity) subject.onBeforeSave(new NoSequenceEntity(),
|
||||
MutableAggregateChange.forSave(new NoSequenceEntity()));
|
||||
|
||||
@@ -37,18 +37,26 @@ public class MySqlDialect extends AbstractDialect {
|
||||
|
||||
/**
|
||||
* MySQL defaults for {@link IdentifierProcessing}.
|
||||
*
|
||||
* @deprecated Construct your own {@link IdentifierProcessing}. There is no one standard identifier processing for
|
||||
* MySql.See
|
||||
*
|
||||
* <pre>
|
||||
* <a href=
|
||||
"https://dev.mysql.com/doc/refman/8.4/en/identifier-case-sensitivity.html">Identifier Case Sensitivity</a>
|
||||
* </pre>
|
||||
*/
|
||||
public static final IdentifierProcessing MYSQL_IDENTIFIER_PROCESSING = IdentifierProcessing.create(new Quoting("`"),
|
||||
LetterCasing.LOWER_CASE);
|
||||
@Deprecated(forRemoval = true,
|
||||
since = "4.0") public static final IdentifierProcessing MYSQL_IDENTIFIER_PROCESSING = IdentifierProcessing
|
||||
.create(new Quoting("`"), LetterCasing.LOWER_CASE);
|
||||
|
||||
/**
|
||||
* Singleton instance.
|
||||
*
|
||||
* @deprecated use either the {@code org.springframework.data.r2dbc.dialect.MySqlDialect} or
|
||||
* {@code org.springframework.data.jdbc.core.dialect.JdbcMySqlDialect}
|
||||
* {@code org.springframework.data.jdbc.core.dialect.JdbcMySqlDialect}
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public static final MySqlDialect INSTANCE = new MySqlDialect();
|
||||
@Deprecated(forRemoval = true) public static final MySqlDialect INSTANCE = new MySqlDialect();
|
||||
|
||||
private final IdentifierProcessing identifierProcessing;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user