Polishing.
Correctly assign SQL type for tuples. See #1323 Original pull request: #1838
This commit is contained in:
@@ -41,6 +41,7 @@ import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.config.PropertiesFactoryBean;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
@@ -66,6 +67,7 @@ import org.springframework.data.jdbc.repository.query.Query;
|
||||
import org.springframework.data.jdbc.repository.support.JdbcRepositoryFactory;
|
||||
import org.springframework.data.jdbc.testing.ConditionalOnDatabase;
|
||||
import org.springframework.data.jdbc.testing.DatabaseType;
|
||||
import org.springframework.data.jdbc.testing.EnabledOnDatabase;
|
||||
import org.springframework.data.jdbc.testing.EnabledOnFeature;
|
||||
import org.springframework.data.jdbc.testing.IntegrationTest;
|
||||
import org.springframework.data.jdbc.testing.TestConfiguration;
|
||||
@@ -107,6 +109,7 @@ import org.springframework.test.jdbc.JdbcTestUtils;
|
||||
* @author Paul Jones
|
||||
*/
|
||||
@IntegrationTest
|
||||
@EnabledOnDatabase(DatabaseType.MARIADB)
|
||||
public class JdbcRepositoryIntegrationTests {
|
||||
|
||||
@Autowired NamedParameterJdbcTemplate template;
|
||||
@@ -1339,15 +1342,15 @@ public class JdbcRepositoryIntegrationTests {
|
||||
}
|
||||
|
||||
@Test // GH-1323
|
||||
@EnabledOnFeature(TestDatabaseFeatures.Feature.WHERE_IN_TUPLE)
|
||||
void queryWithTupleIn() {
|
||||
|
||||
DummyEntity one = repository.save(createDummyEntity("one"));
|
||||
DummyEntity two = repository.save(createDummyEntity( "two"));
|
||||
DummyEntity three = repository.save(createDummyEntity( "three"));
|
||||
DummyEntity two = repository.save(createDummyEntity("two"));
|
||||
DummyEntity three = repository.save(createDummyEntity("three"));
|
||||
|
||||
List<Object[]> tuples = List.of(
|
||||
new Object[]{two.idProp, "two"}, // matches "two"
|
||||
new Object[]{three.idProp, "two"} // matches nothing
|
||||
List<Object[]> tuples = List.of(new Object[] { two.idProp, "two" }, // matches "two"
|
||||
new Object[] { three.idProp, "two" } // matches nothing
|
||||
);
|
||||
|
||||
List<DummyEntity> result = repository.findByListInTuple(tuples);
|
||||
@@ -1887,6 +1890,11 @@ public class JdbcRepositoryIntegrationTests {
|
||||
public int hashCode() {
|
||||
return Objects.hash(name, pointInTime, offsetDateTime, idProp, flag, ref, direction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DummyEntity{" + "name='" + name + '\'' + ", idProp=" + idProp + '}';
|
||||
}
|
||||
}
|
||||
|
||||
enum Direction {
|
||||
|
||||
@@ -49,6 +49,7 @@ import org.springframework.data.jdbc.core.convert.JdbcTypeFactory;
|
||||
import org.springframework.data.jdbc.core.convert.MappingJdbcConverter;
|
||||
import org.springframework.data.jdbc.core.convert.RelationResolver;
|
||||
import org.springframework.data.jdbc.core.mapping.JdbcValue;
|
||||
import org.springframework.data.jdbc.support.JdbcUtil;
|
||||
import org.springframework.data.projection.SpelAwareProxyProjectionFactory;
|
||||
import org.springframework.data.relational.core.mapping.RelationalMappingContext;
|
||||
import org.springframework.data.repository.Repository;
|
||||
@@ -338,6 +339,8 @@ class StringBasedJdbcQueryUnitTests {
|
||||
assertThat(parameterSource.getValue("tuples"))
|
||||
.asInstanceOf(LIST)
|
||||
.containsExactly(tuples);
|
||||
|
||||
assertThat(parameterSource.getSqlType("tuples")).isEqualTo(JdbcUtil.TYPE_UNKNOWN.getVendorTypeNumber());
|
||||
}
|
||||
|
||||
@Test // GH-1323
|
||||
|
||||
@@ -79,6 +79,10 @@ public class TestDatabaseFeatures {
|
||||
assumeThat(database).isNotIn(Database.MySql, Database.MariaDb, Database.SqlServer);
|
||||
}
|
||||
|
||||
private void supportsWhereInTuples() {
|
||||
assumeThat(database).isIn(Database.MySql, Database.PostgreSql);
|
||||
}
|
||||
|
||||
public void databaseIs(Database database) {
|
||||
assumeThat(this.database).isEqualTo(database);
|
||||
}
|
||||
@@ -112,6 +116,7 @@ public class TestDatabaseFeatures {
|
||||
SUPPORTS_NANOSECOND_PRECISION(TestDatabaseFeatures::supportsNanosecondPrecision), //
|
||||
SUPPORTS_NULL_PRECEDENCE(TestDatabaseFeatures::supportsNullPrecedence),
|
||||
IS_POSTGRES(f -> f.databaseIs(Database.PostgreSql)), //
|
||||
WHERE_IN_TUPLE(TestDatabaseFeatures::supportsWhereInTuples), //
|
||||
IS_HSQL(f -> f.databaseIs(Database.Hsql));
|
||||
|
||||
private final Consumer<TestDatabaseFeatures> featureMethod;
|
||||
|
||||
Reference in New Issue
Block a user