diff --git a/pom.xml b/pom.xml
index ebd3103251..9ad5010b18 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
org.springframework.data
spring-data-relational-parent
- 4.0.0-SNAPSHOT
+ 4.0.0-1993-force-quoting-SNAPSHOT
pom
Spring Data Relational Parent
diff --git a/spring-data-jdbc-distribution/pom.xml b/spring-data-jdbc-distribution/pom.xml
index b3c39e64c3..c0cf7c24a7 100644
--- a/spring-data-jdbc-distribution/pom.xml
+++ b/spring-data-jdbc-distribution/pom.xml
@@ -14,7 +14,7 @@
org.springframework.data
spring-data-relational-parent
- 4.0.0-SNAPSHOT
+ 4.0.0-1993-force-quoting-SNAPSHOT
../pom.xml
diff --git a/spring-data-jdbc/pom.xml b/spring-data-jdbc/pom.xml
index e61fd64020..753b0846d2 100644
--- a/spring-data-jdbc/pom.xml
+++ b/spring-data-jdbc/pom.xml
@@ -6,7 +6,7 @@
4.0.0
spring-data-jdbc
- 4.0.0-SNAPSHOT
+ 4.0.0-1993-force-quoting-SNAPSHOT
Spring Data JDBC
Spring Data module for JDBC repositories.
@@ -15,7 +15,7 @@
org.springframework.data
spring-data-relational-parent
- 4.0.0-SNAPSHOT
+ 4.0.0-1993-force-quoting-SNAPSHOT
diff --git a/spring-data-r2dbc/pom.xml b/spring-data-r2dbc/pom.xml
index 3ee76fd3c1..f228bc9bcb 100644
--- a/spring-data-r2dbc/pom.xml
+++ b/spring-data-r2dbc/pom.xml
@@ -6,7 +6,7 @@
4.0.0
spring-data-r2dbc
- 4.0.0-SNAPSHOT
+ 4.0.0-1993-force-quoting-SNAPSHOT
Spring Data R2DBC
Spring Data module for R2DBC
@@ -15,7 +15,7 @@
org.springframework.data
spring-data-relational-parent
- 4.0.0-SNAPSHOT
+ 4.0.0-1993-force-quoting-SNAPSHOT
diff --git a/spring-data-r2dbc/src/main/java/org/springframework/data/r2dbc/mapping/R2dbcMappingContext.java b/spring-data-r2dbc/src/main/java/org/springframework/data/r2dbc/mapping/R2dbcMappingContext.java
index 5053291be6..3a9fdf3604 100644
--- a/spring-data-r2dbc/src/main/java/org/springframework/data/r2dbc/mapping/R2dbcMappingContext.java
+++ b/spring-data-r2dbc/src/main/java/org/springframework/data/r2dbc/mapping/R2dbcMappingContext.java
@@ -32,7 +32,7 @@ public class R2dbcMappingContext extends RelationalMappingContext {
* Create a new {@link R2dbcMappingContext}.
*/
public R2dbcMappingContext() {
- setForceQuote(false);
+ setForceQuote(true);
}
/**
@@ -41,8 +41,10 @@ public R2dbcMappingContext() {
* @param namingStrategy must not be {@literal null}.
*/
public R2dbcMappingContext(NamingStrategy namingStrategy) {
+
super(namingStrategy);
- setForceQuote(false);
+
+ setForceQuote(true);
}
@Override
diff --git a/spring-data-r2dbc/src/test/java/org/springframework/data/r2dbc/core/ReactiveDataAccessStrategyTestSupport.java b/spring-data-r2dbc/src/test/java/org/springframework/data/r2dbc/core/ReactiveDataAccessStrategyTestSupport.java
index 77b855b6bf..e187dca08a 100644
--- a/spring-data-r2dbc/src/test/java/org/springframework/data/r2dbc/core/ReactiveDataAccessStrategyTestSupport.java
+++ b/spring-data-r2dbc/src/test/java/org/springframework/data/r2dbc/core/ReactiveDataAccessStrategyTestSupport.java
@@ -185,7 +185,7 @@ void shouldNotWriteReadOnlyFields() {
toSave.readOnlyField = "readonly";
toSave.readOnlyArrayField = "readonly_array".getBytes();
- assertThat(getStrategy().getOutboundRow(toSave)).containsOnlyKeys(SqlIdentifier.unquoted("writable_field"));
+ assertThat(getStrategy().getOutboundRow(toSave)).containsOnlyKeys(SqlIdentifier.quoted("writable_field"));
}
private void testType(BiConsumer setter, Function getter, T testValue,
@@ -201,7 +201,7 @@ private void testType(BiConsumer setter, Function ?[$5]))");
+ "(person.\"NAME\" = ?[$1]) AND (person.\"NAME\" = ?[$2] OR person.age < ?[$3] OR (person.\"NAME\" != ?[$4] AND person.age > ?[$5]))");
}
@Test // gh-289
@@ -150,7 +152,7 @@ void shouldMapFrom() {
BoundCondition bindings = map(criteria);
assertThat(bindings.getCondition())
- .hasToString("person.name = ?[$1] AND (person.name = ?[$2] OR person.age < ?[$3])");
+ .hasToString("person.\"NAME\" = ?[$1] AND (person.\"NAME\" = ?[$2] OR person.age < ?[$3])");
}
@Test // gh-383
@@ -160,13 +162,13 @@ void shouldMapFromConcat() {
.or("age").lessThan(49));
assertThat(map(criteria).getCondition())
- .hasToString("(person.name = ?[$1] AND (person.name = ?[$2] OR person.age < ?[$3]))");
+ .hasToString("(person.\"NAME\" = ?[$1] AND (person.\"NAME\" = ?[$2] OR person.age < ?[$3]))");
criteria = Criteria.from(Criteria.where("name").is("Foo"), Criteria.where("name").is("Bar") //
.or("age").lessThan(49), Criteria.where("foo").is("bar"));
assertThat(map(criteria).getCondition())
- .hasToString("(person.name = ?[$1] AND (person.name = ?[$2] OR person.age < ?[$3]) AND (person.foo = ?[$4]))");
+ .hasToString("(person.\"NAME\" = ?[$1] AND (person.\"NAME\" = ?[$2] OR person.age < ?[$3]) AND (person.foo = ?[$4]))");
}
@Test // gh-64
@@ -176,7 +178,7 @@ void shouldMapSimpleCriteria() {
BoundCondition bindings = map(criteria);
- assertThat(bindings.getCondition()).hasToString("person.name = ?[$1]");
+ assertThat(bindings.getCondition()).hasToString("person.\"NAME\" = ?[$1]");
bindings.getBindings().apply(bindTarget);
verify(bindTarget).bind(0, "foo");
@@ -218,7 +220,7 @@ void shouldMapExpression() {
Expression mappedObject = mapper.getMappedObject(table.column("alternative").as("my_aliased_col"),
mapper.getMappingContext().getRequiredPersistentEntity(Person.class));
- assertThat(mappedObject).hasToString("my_aliased_table.another_name AS my_aliased_col");
+ assertThat(mappedObject).hasToString("my_aliased_table.\"another_name\" AS my_aliased_col");
}
@Test // gh-300
@@ -229,7 +231,7 @@ void shouldMapCountFunction() {
Expression mappedObject = mapper.getMappedObject(Functions.count(table.column("alternative")),
mapper.getMappingContext().getRequiredPersistentEntity(Person.class));
- assertThat(mappedObject).hasToString("COUNT(my_aliased_table.another_name)");
+ assertThat(mappedObject).hasToString("COUNT(my_aliased_table.\"another_name\")");
}
@Test // gh-300
@@ -260,7 +262,7 @@ void shouldMapSimpleNullableCriteria() {
BoundCondition bindings = map(criteria);
- assertThat(bindings.getCondition()).hasToString("person.name = ?[$1]");
+ assertThat(bindings.getCondition()).hasToString("person.\"NAME\" = ?[$1]");
bindings.getBindings().apply(bindTarget);
verify(bindTarget).bindNull(0, Integer.class);
@@ -273,7 +275,7 @@ void shouldConsiderColumnName() {
BoundCondition bindings = map(criteria);
- assertThat(bindings.getCondition()).hasToString("person.another_name = ?[$1]");
+ assertThat(bindings.getCondition()).hasToString("person.\"another_name\" = ?[$1]");
}
@Test // gh-64
@@ -283,7 +285,7 @@ void shouldMapAndCriteria() {
BoundCondition bindings = map(criteria);
- assertThat(bindings.getCondition()).hasToString("person.name = ?[$1] AND person.bar = ?[$2]");
+ assertThat(bindings.getCondition()).hasToString("person.\"NAME\" = ?[$1] AND person.bar = ?[$2]");
bindings.getBindings().apply(bindTarget);
verify(bindTarget).bind(0, "foo");
@@ -297,7 +299,7 @@ void shouldMapOrCriteria() {
BoundCondition bindings = map(criteria);
- assertThat(bindings.getCondition()).hasToString("person.name = ?[$1] OR person.bar = ?[$2]");
+ assertThat(bindings.getCondition()).hasToString("person.\"NAME\" = ?[$1] OR person.bar = ?[$2]");
}
@Test // gh-64
@@ -311,7 +313,7 @@ void shouldMapAndOrCriteria() {
BoundCondition bindings = map(criteria);
assertThat(bindings.getCondition()).hasToString(
- "person.name = ?[$1] AND person.name IS NOT NULL OR person.bar = ?[$2] AND person.anotherOne = ?[$3]");
+ "person.\"NAME\" = ?[$1] AND person.\"NAME\" IS NOT NULL OR person.bar = ?[$2] AND person.anotherOne = ?[$3]");
}
@Test // gh-64
@@ -321,7 +323,7 @@ void shouldMapNeq() {
BoundCondition bindings = map(criteria);
- assertThat(bindings.getCondition()).hasToString("person.name != ?[$1]");
+ assertThat(bindings.getCondition()).hasToString("person.\"NAME\" != ?[$1]");
}
@Test // gh-64
@@ -331,7 +333,7 @@ void shouldMapIsNull() {
BoundCondition bindings = map(criteria);
- assertThat(bindings.getCondition()).hasToString("person.name IS NULL");
+ assertThat(bindings.getCondition()).hasToString("person.\"NAME\" IS NULL");
}
@Test // gh-64
@@ -341,7 +343,7 @@ void shouldMapIsNotNull() {
BoundCondition bindings = map(criteria);
- assertThat(bindings.getCondition()).hasToString("person.name IS NOT NULL");
+ assertThat(bindings.getCondition()).hasToString("person.\"NAME\" IS NOT NULL");
}
@Test // gh-64
@@ -351,7 +353,7 @@ void shouldMapIsIn() {
BoundCondition bindings = map(criteria);
- assertThat(bindings.getCondition()).hasToString("person.name IN (?[$1], ?[$2], ?[$3])");
+ assertThat(bindings.getCondition()).hasToString("person.\"NAME\" IN (?[$1], ?[$2], ?[$3])");
}
@Test // gh-64, gh-177
@@ -361,7 +363,7 @@ void shouldMapIsNotIn() {
BoundCondition bindings = map(criteria);
- assertThat(bindings.getCondition()).hasToString("person.name NOT IN (?[$1], ?[$2], ?[$3])");
+ assertThat(bindings.getCondition()).hasToString("person.\"NAME\" NOT IN (?[$1], ?[$2], ?[$3])");
}
@Test
@@ -374,7 +376,7 @@ void shouldMapIsNotInWithCollectionToStringConverter() {
BoundCondition bindings = map(criteria);
- assertThat(bindings.getCondition()).hasToString("person.name NOT IN (?[$1], ?[$2], ?[$3])");
+ assertThat(bindings.getCondition()).hasToString("person.\"NAME\" NOT IN (?[$1], ?[$2], ?[$3])");
}
@Test // gh-64
@@ -384,7 +386,7 @@ void shouldMapIsGt() {
BoundCondition bindings = map(criteria);
- assertThat(bindings.getCondition()).hasToString("person.name > ?[$1]");
+ assertThat(bindings.getCondition()).hasToString("person.\"NAME\" > ?[$1]");
}
@Test // gh-64
@@ -394,7 +396,7 @@ void shouldMapIsGte() {
BoundCondition bindings = map(criteria);
- assertThat(bindings.getCondition()).hasToString("person.name >= ?[$1]");
+ assertThat(bindings.getCondition()).hasToString("person.\"NAME\" >= ?[$1]");
}
@Test // gh-64
@@ -404,7 +406,7 @@ void shouldMapIsLt() {
BoundCondition bindings = map(criteria);
- assertThat(bindings.getCondition()).hasToString("person.name < ?[$1]");
+ assertThat(bindings.getCondition()).hasToString("person.\"NAME\" < ?[$1]");
}
@Test // gh-64
@@ -414,7 +416,7 @@ void shouldMapIsLte() {
BoundCondition bindings = map(criteria);
- assertThat(bindings.getCondition()).hasToString("person.name <= ?[$1]");
+ assertThat(bindings.getCondition()).hasToString("person.\"NAME\" <= ?[$1]");
}
@Test // gh-64
@@ -424,7 +426,7 @@ void shouldMapIsLike() {
BoundCondition bindings = map(criteria);
- assertThat(bindings.getCondition()).hasToString("person.name LIKE ?[$1]");
+ assertThat(bindings.getCondition()).hasToString("person.\"NAME\" LIKE ?[$1]");
}
@Test // GH-1507
@@ -493,7 +495,7 @@ void mapQueryForEnumArrayShouldMapToStringList() {
BoundCondition bindings = map(criteria);
- assertThat(bindings.getCondition()).hasToString("person.enum_value IN (?[$1], ?[$2])");
+ assertThat(bindings.getCondition()).hasToString("person.\"ENUM_VALUE\" IN (?[$1], ?[$2])");
}
@Test // gh-733
@@ -503,7 +505,7 @@ void shouldMapBooleanConditionProperly() {
BoundCondition bindings = map(criteria);
- assertThat(bindings.getCondition()).hasToString("person.state = ?[$1]");
+ assertThat(bindings.getCondition()).hasToString("person.\"STATE\" = ?[$1]");
assertThat(bindings.getBindings().iterator().next().getValue()).isEqualTo(false);
}
@@ -515,7 +517,7 @@ void shouldMapAndConvertBooleanConditionProperly() {
BoundCondition bindings = map(criteria);
- assertThat(bindings.getCondition()).hasToString("person.state = ?[$1]");
+ assertThat(bindings.getCondition()).hasToString("person.\"STATE\" = ?[$1]");
assertThat(bindings.getBindings().iterator().next().getValue()).isEqualTo((byte) 1);
}
@@ -526,7 +528,7 @@ void shouldMapJsonNodeToString() {
BoundCondition bindings = map(criteria);
- assertThat(bindings.getCondition()).hasToString("person.json_node = ?[$1]");
+ assertThat(bindings.getCondition()).hasToString("person.\"JSON_NODE\" = ?[$1]");
assertThat(bindings.getBindings().iterator().next().getValue()).isEqualTo("foo");
}
@@ -537,7 +539,7 @@ void shouldMapJsonNodeListToString() {
BoundCondition bindings = map(criteria);
- assertThat(bindings.getCondition()).hasToString("person.json_node IN (?[$1], ?[$2])");
+ assertThat(bindings.getCondition()).hasToString("person.\"JSON_NODE\" IN (?[$1], ?[$2])");
assertThat(bindings.getBindings().iterator().next().getValue()).isEqualTo("foo");
}
diff --git a/spring-data-r2dbc/src/test/java/org/springframework/data/r2dbc/query/UpdateMapperUnitTests.java b/spring-data-r2dbc/src/test/java/org/springframework/data/r2dbc/query/UpdateMapperUnitTests.java
index 6bb448d4b3..1a9eed2727 100644
--- a/spring-data-r2dbc/src/test/java/org/springframework/data/r2dbc/query/UpdateMapperUnitTests.java
+++ b/spring-data-r2dbc/src/test/java/org/springframework/data/r2dbc/query/UpdateMapperUnitTests.java
@@ -60,7 +60,7 @@ void shouldMapFieldNamesInUpdate() {
Map assignments = mapped.getAssignments().stream().map(it -> (AssignValue) it)
.collect(Collectors.toMap(k -> k.getColumn().getName(), AssignValue::getValue));
- assertThat(assignments).containsEntry(SqlIdentifier.unquoted("another_name"), SQL.bindMarker("$1"));
+ assertThat(assignments).containsEntry(SqlIdentifier.quoted("another_name"), SQL.bindMarker("$1"));
}
@Test // gh-64
@@ -73,7 +73,7 @@ void shouldUpdateToSettableValue() {
Map assignments = mapped.getAssignments().stream().map(it -> (AssignValue) it)
.collect(Collectors.toMap(k -> k.getColumn().getName(), AssignValue::getValue));
- assertThat(assignments).containsEntry(SqlIdentifier.unquoted("another_name"), SQL.bindMarker("$1"));
+ assertThat(assignments).containsEntry(SqlIdentifier.quoted("another_name"), SQL.bindMarker("$1"));
mapped.getBindings().apply(bindTarget);
verify(bindTarget).bindNull(0, String.class);
@@ -87,7 +87,7 @@ void shouldUpdateToNull() {
BoundAssignments mapped = map(update);
assertThat(mapped.getAssignments()).hasSize(1);
- assertThat(mapped.getAssignments().get(0).toString()).isEqualTo("person.another_name = NULL");
+ assertThat(mapped.getAssignments().get(0).toString()).isEqualTo("person.\"another_name\" = NULL");
mapped.getBindings().apply(bindTarget);
verifyNoInteractions(bindTarget);
diff --git a/spring-data-r2dbc/src/test/java/org/springframework/data/r2dbc/repository/query/PartTreeR2dbcQueryUnitTests.java b/spring-data-r2dbc/src/test/java/org/springframework/data/r2dbc/repository/query/PartTreeR2dbcQueryUnitTests.java
index d631130d17..48074d7ab1 100644
--- a/spring-data-r2dbc/src/test/java/org/springframework/data/r2dbc/repository/query/PartTreeR2dbcQueryUnitTests.java
+++ b/spring-data-r2dbc/src/test/java/org/springframework/data/r2dbc/repository/query/PartTreeR2dbcQueryUnitTests.java
@@ -77,9 +77,9 @@
@MockitoSettings(strictness = Strictness.LENIENT)
class PartTreeR2dbcQueryUnitTests {
- private static final String TABLE = "users";
- private static final String[] ALL_FIELDS_ARRAY = new String[] { ".id", ".first_name", ".last_name", ".date_of_birth",
- ".age", ".active" };
+ private static final String TABLE = "\"users\"";
+ private static final String[] ALL_FIELDS_ARRAY = new String[] { ".\"id\"", ".\"first_name\"", ".\"last_name\"", ".\"date_of_birth\"",
+ ".\"age\"", ".\"active\"" };
private static final String[] ALL_FIELDS_ARRAY_PREFIXED = Arrays.stream(ALL_FIELDS_ARRAY).map(f -> TABLE + f)
.toArray(String[]::new);
private static final String ALL_FIELDS = String.join(", ", ALL_FIELDS_ARRAY_PREFIXED);
@@ -121,7 +121,7 @@ void createsQueryToFindAllEntitiesByStringAttribute() throws Exception {
PreparedOperationAssert.assertThat(preparedOperation) //
.selects(ALL_FIELDS_ARRAY_PREFIXED) //
.from(TABLE) //
- .where(TABLE + ".first_name = $1");
+ .where(TABLE + ".\"first_name\" = $1");
}
@Test // GH-282
@@ -134,7 +134,7 @@ void createsQueryWithIsNullCondition() throws Exception {
PreparedOperationAssert.assertThat(preparedOperation) //
.selects(ALL_FIELDS_ARRAY_PREFIXED) //
.from(TABLE) //
- .where(TABLE + ".first_name IS NULL");
+ .where(TABLE + ".\"first_name\" IS NULL");
}
@Test // GH-282
@@ -145,9 +145,9 @@ void createsQueryWithLimitForExistsProjection() throws Exception {
PreparedOperation> query = createQuery(queryMethod, r2dbcQuery, "John");
PreparedOperationAssert.assertThat(query) //
- .selects(TABLE + ".id") //
+ .selects(TABLE + ".\"id\"") //
.from(TABLE) //
- .where(TABLE + ".first_name = $1 LIMIT 1");
+ .where(TABLE + ".\"first_name\" = $1 LIMIT 1");
}
@Test // GH-282
@@ -161,7 +161,7 @@ void createsQueryToFindAllEntitiesByTwoStringAttributes() throws Exception {
PreparedOperationAssert.assertThat(preparedOperation) //
.selects(ALL_FIELDS_ARRAY_PREFIXED) //
.from(TABLE) //
- .where(TABLE + ".last_name = $1 AND (" + TABLE + ".first_name = $2)");
+ .where(TABLE + ".\"last_name\" = $1 AND (" + TABLE + ".\"first_name\" = $2)");
}
@Test // GH-282
@@ -175,7 +175,7 @@ void createsQueryToFindAllEntitiesByOneOfTwoStringAttributes() throws Exception
PreparedOperationAssert.assertThat(preparedOperation) //
.selects(ALL_FIELDS_ARRAY_PREFIXED) //
.from(TABLE) //
- .where(TABLE + ".last_name = $1 OR (" + TABLE + ".first_name = $2)");
+ .where(TABLE + ".\"last_name\" = $1 OR (" + TABLE + ".\"first_name\" = $2)");
}
@Test // GH-282, GH-349
@@ -191,7 +191,7 @@ void createsQueryToFindAllEntitiesByDateAttributeBetween() throws Exception {
PreparedOperationAssert.assertThat(preparedOperation) //
.selects(ALL_FIELDS_ARRAY_PREFIXED) //
.from(TABLE) //
- .where(TABLE + ".date_of_birth BETWEEN $1 AND $2");
+ .where(TABLE + ".\"date_of_birth\" BETWEEN $1 AND $2");
BindTarget bindTarget = mock(BindTarget.class);
preparedOperation.bindTo(bindTarget);
@@ -211,7 +211,7 @@ void createsQueryToFindAllEntitiesByIntegerAttributeLessThan() throws Exception
PreparedOperationAssert.assertThat(preparedOperation) //
.selects(ALL_FIELDS_ARRAY_PREFIXED) //
.from(TABLE) //
- .where(TABLE + ".age < $1");
+ .where(TABLE + ".\"age\" < $1");
}
@Test // GH-282
@@ -225,7 +225,7 @@ void createsQueryToFindAllEntitiesByIntegerAttributeLessThanEqual() throws Excep
PreparedOperationAssert.assertThat(preparedOperation) //
.selects(ALL_FIELDS_ARRAY_PREFIXED) //
.from(TABLE) //
- .where(TABLE + ".age <= $1");
+ .where(TABLE + ".\"age\" <= $1");
}
@Test // GH-282
@@ -239,7 +239,7 @@ void createsQueryToFindAllEntitiesByIntegerAttributeGreaterThan() throws Excepti
PreparedOperationAssert.assertThat(preparedOperation) //
.selects(ALL_FIELDS_ARRAY_PREFIXED) //
.from(TABLE) //
- .where(TABLE + ".age > $1");
+ .where(TABLE + ".\"age\" > $1");
}
@Test // GH-282
@@ -253,7 +253,7 @@ void createsQueryToFindAllEntitiesByIntegerAttributeGreaterThanEqual() throws Ex
PreparedOperationAssert.assertThat(preparedOperation) //
.selects(ALL_FIELDS_ARRAY_PREFIXED) //
.from(TABLE) //
- .where(TABLE + ".age >= $1");
+ .where(TABLE + ".\"age\" >= $1");
}
@Test // GH-282
@@ -267,7 +267,7 @@ void createsQueryToFindAllEntitiesByDateAttributeAfter() throws Exception {
PreparedOperationAssert.assertThat(preparedOperation) //
.selects(ALL_FIELDS_ARRAY_PREFIXED) //
.from(TABLE) //
- .where(TABLE + ".date_of_birth > $1");
+ .where(TABLE + ".\"date_of_birth\" > $1");
}
@Test // GH-282
@@ -280,7 +280,7 @@ void createsQueryToFindAllEntitiesByDateAttributeBefore() throws Exception {
PreparedOperationAssert.assertThat(preparedOperation) //
.selects(ALL_FIELDS_ARRAY_PREFIXED) //
.from(TABLE) //
- .where(TABLE + ".date_of_birth < $1");
+ .where(TABLE + ".\"date_of_birth\" < $1");
}
@Test // GH-282
@@ -294,7 +294,7 @@ void createsQueryToFindAllEntitiesByIntegerAttributeIsNull() throws Exception {
PreparedOperationAssert.assertThat(preparedOperation) //
.selects(ALL_FIELDS_ARRAY_PREFIXED) //
.from(TABLE) //
- .where(TABLE + ".age IS NULL");
+ .where(TABLE + ".\"age\" IS NULL");
}
@Test // GH-282
@@ -308,7 +308,7 @@ void createsQueryToFindAllEntitiesByIntegerAttributeIsNotNull() throws Exception
PreparedOperationAssert.assertThat(preparedOperation) //
.selects(ALL_FIELDS_ARRAY_PREFIXED) //
.from(TABLE) //
- .where(TABLE + ".age IS NOT NULL");
+ .where(TABLE + ".\"age\" IS NOT NULL");
}
@Test // GH-282
@@ -322,7 +322,7 @@ void createsQueryToFindAllEntitiesByStringAttributeLike() throws Exception {
PreparedOperationAssert.assertThat(preparedOperation) //
.selects(ALL_FIELDS_ARRAY_PREFIXED) //
.from(TABLE) //
- .where(TABLE + ".first_name LIKE $1");
+ .where(TABLE + ".\"first_name\" LIKE $1");
}
@Test // GH-282
@@ -336,7 +336,7 @@ void createsQueryToFindAllEntitiesByStringAttributeNotLike() throws Exception {
PreparedOperationAssert.assertThat(preparedOperation) //
.selects(ALL_FIELDS_ARRAY_PREFIXED) //
.from(TABLE) //
- .where(TABLE + ".first_name NOT LIKE $1");
+ .where(TABLE + ".\"first_name\" NOT LIKE $1");
}
@Test // GH-282
@@ -350,7 +350,7 @@ void createsQueryToFindAllEntitiesByStringAttributeStartingWith() throws Excepti
PreparedOperationAssert.assertThat(preparedOperation) //
.selects(ALL_FIELDS_ARRAY_PREFIXED) //
.from(TABLE) //
- .where(TABLE + ".first_name LIKE $1");
+ .where(TABLE + ".\"first_name\" LIKE $1");
}
@Test // GH-282
@@ -377,7 +377,7 @@ void createsQueryToFindAllEntitiesByStringAttributeEndingWith() throws Exception
PreparedOperationAssert.assertThat(preparedOperation) //
.selects(ALL_FIELDS_ARRAY_PREFIXED) //
.from(TABLE) //
- .where(TABLE + ".first_name LIKE $1");
+ .where(TABLE + ".\"first_name\" LIKE $1");
}
@Test // GH-282
@@ -404,7 +404,7 @@ void createsQueryToFindAllEntitiesByStringAttributeContaining() throws Exception
PreparedOperationAssert.assertThat(preparedOperation) //
.selects(ALL_FIELDS_ARRAY_PREFIXED) //
.from(TABLE) //
- .where(TABLE + ".first_name LIKE $1");
+ .where(TABLE + ".\"first_name\" LIKE $1");
}
@Test // GH-282
@@ -431,7 +431,7 @@ void createsQueryToFindAllEntitiesByStringAttributeNotContaining() throws Except
PreparedOperationAssert.assertThat(preparedOperation) //
.selects(ALL_FIELDS_ARRAY_PREFIXED) //
.from(TABLE) //
- .where(TABLE + ".first_name NOT LIKE $1");
+ .where(TABLE + ".\"first_name\" NOT LIKE $1");
}
@Test // GH-282
@@ -457,8 +457,8 @@ void createsQueryToFindAllEntitiesByIntegerAttributeWithDescendingOrderingByStri
PreparedOperationAssert.assertThat(preparedOperation) //
.selects(ALL_FIELDS_ARRAY_PREFIXED) //
.from(TABLE) //
- .where(TABLE + ".age = $1") //
- .orderBy("users.last_name DESC");
+ .where(TABLE + ".\"age\" = $1") //
+ .orderBy("\"users\".\"last_name\" DESC");
}
@Test // GH-282
@@ -472,8 +472,8 @@ void createsQueryToFindAllEntitiesByIntegerAttributeWithAscendingOrderingByStrin
PreparedOperationAssert.assertThat(preparedOperation) //
.selects(ALL_FIELDS_ARRAY_PREFIXED) //
.from(TABLE) //
- .where(TABLE + ".age = $1") //
- .orderBy("users.last_name ASC");
+ .where(TABLE + ".\"age\" = $1") //
+ .orderBy("\"users\".\"last_name\" ASC");
}
@Test // GH-282
@@ -487,7 +487,7 @@ void createsQueryToFindAllEntitiesByStringAttributeNot() throws Exception {
PreparedOperationAssert.assertThat(preparedOperation) //
.selects(ALL_FIELDS_ARRAY_PREFIXED) //
.from(TABLE) //
- .where(TABLE + ".last_name != $1");
+ .where(TABLE + ".\"last_name\" != $1");
}
@Test // GH-282
@@ -502,7 +502,7 @@ void createsQueryToFindAllEntitiesByIntegerAttributeIn() throws Exception {
PreparedOperationAssert.assertThat(preparedOperation) //
.selects(ALL_FIELDS_ARRAY_PREFIXED) //
.from(TABLE) //
- .where(TABLE + ".age IN ($1)");
+ .where(TABLE + ".\"age\" IN ($1)");
}
@Test // GH-282
@@ -517,7 +517,7 @@ void createsQueryToFindAllEntitiesByIntegerAttributeNotIn() throws Exception {
PreparedOperationAssert.assertThat(preparedOperation) //
.selects(ALL_FIELDS_ARRAY_PREFIXED) //
.from(TABLE) //
- .where(TABLE + ".age NOT IN ($1)");
+ .where(TABLE + ".\"age\" NOT IN ($1)");
}
@Test // GH-282, GH-698
@@ -531,7 +531,7 @@ void createsQueryToFindAllEntitiesByBooleanAttributeTrue() throws Exception {
PreparedOperationAssert.assertThat(preparedOperation) //
.selects(ALL_FIELDS_ARRAY_PREFIXED) //
.from(TABLE) //
- .where(TABLE + ".active = $1");
+ .where(TABLE + ".\"active\" = $1");
}
@Test // GH-282, GH-698
@@ -545,7 +545,7 @@ void createsQueryToFindAllEntitiesByBooleanAttributeFalse() throws Exception {
PreparedOperationAssert.assertThat(preparedOperation) //
.selects(ALL_FIELDS_ARRAY_PREFIXED) //
.from(TABLE) //
- .where(TABLE + ".active = $1");
+ .where(TABLE + ".\"active\" = $1");
}
@Test // GH-282
@@ -559,7 +559,7 @@ void createsQueryToFindAllEntitiesByStringAttributeIgnoringCase() throws Excepti
PreparedOperationAssert.assertThat(preparedOperation) //
.selects(ALL_FIELDS_ARRAY_PREFIXED) //
.from(TABLE) //
- .where("UPPER(" + TABLE + ".first_name) = UPPER($1)");
+ .where("UPPER(" + TABLE + ".\"first_name\") = UPPER($1)");
}
@Test // GH-282
@@ -608,7 +608,7 @@ void allowsSortingByNonDomainProperties() throws Exception {
PreparedOperation> preparedOperation = createQuery(queryMethod, r2dbcQuery, "foo", Sort.by("foobar"));
PreparedOperationAssert.assertThat(preparedOperation) //
- .orderBy("users.foobar ASC");
+ .orderBy("\"users\".foobar ASC");
preparedOperation = createQuery(queryMethod, r2dbcQuery, "foo", SqlSort.unsafe(Direction.ASC, "sum(foobar)"));
PreparedOperationAssert.assertThat(preparedOperation) //
@@ -636,7 +636,7 @@ void createsQueryWithLimitToFindEntitiesByStringAttribute() throws Exception {
PreparedOperationAssert.assertThat(preparedOperation) //
.selects(ALL_FIELDS_ARRAY_PREFIXED) //
.from(TABLE) //
- .where(TABLE + ".first_name = $1 LIMIT 3");
+ .where(TABLE + ".\"first_name\" = $1 LIMIT 3");
}
@Test // GH-282
@@ -650,7 +650,7 @@ void createsQueryToFindFirstEntityByStringAttribute() throws Exception {
PreparedOperationAssert.assertThat(preparedOperation) //
.selects(ALL_FIELDS_ARRAY_PREFIXED) //
.from(TABLE) //
- .where(TABLE + ".first_name = $1 LIMIT 1");
+ .where(TABLE + ".\"first_name\" = $1 LIMIT 1");
}
@Test // GH-341
@@ -664,7 +664,7 @@ void createsQueryToDeleteByFirstName() throws Exception {
PreparedOperationAssert.assertThat(preparedOperation) //
.deletes() //
.from(TABLE) //
- .where(TABLE + ".first_name = $1");
+ .where(TABLE + ".\"first_name\" = $1");
}
@Test // GH-344
@@ -675,7 +675,7 @@ void createsQueryToFindAllEntitiesByStringAttributeWithDistinct() throws Excepti
PreparedOperation> preparedOperation = createQuery(queryMethod, r2dbcQuery, "John");
PreparedOperationAssert.assertThat(preparedOperation) //
- .selectsDistinct(TABLE + ".first_name", TABLE + ".foo") //
+ .selectsDistinct(TABLE + ".\"first_name\"", TABLE + ".foo") //
.from(TABLE);
}
@@ -688,7 +688,7 @@ void createsQueryToFindByOpenProjection() throws Exception {
PreparedOperation> preparedOperation = createQuery(queryMethod, r2dbcQuery);
PreparedOperationAssert.assertThat(preparedOperation) //
- .selects("users.id", "users.first_name", "users.last_name", "users.date_of_birth", "users.age", "users.active") //
+ .selects("\"users\".\"id\"", "\"users\".\"first_name\"", "\"users\".\"last_name\"", "\"users\".\"date_of_birth\"", "\"users\".\"age\"", "\"users\".\"active\"") //
.from(TABLE);
}
@@ -701,7 +701,7 @@ void createsDtoProjectionQuery() throws Exception {
PreparedOperation> preparedOperation = createQuery(queryMethod, r2dbcQuery, 42);
PreparedOperationAssert.assertThat(preparedOperation) //
- .selects("users.id", "users.first_name", "users.last_name", "users.date_of_birth", "users.age", "users.active") //
+ .selects("\"users\".\"id\"", "\"users\".\"first_name\"", "\"users\".\"last_name\"", "\"users\".\"date_of_birth\"", "\"users\".\"age\"", "\"users\".\"active\"") //
.from(TABLE);
}
@@ -713,9 +713,9 @@ void createsQueryForCountProjection() throws Exception {
PreparedOperation> query = createQuery(queryMethod, r2dbcQuery, "John");
PreparedOperationAssert.assertThat(query) //
- .selects("COUNT(users.id)") //
+ .selects("COUNT(\"users\".\"id\")") //
.from(TABLE) //
- .where(TABLE + ".first_name = $1");
+ .where(TABLE + ".\"first_name\" = $1");
}
@Test // GH-1041
@@ -730,9 +730,9 @@ void createQueryWithPessimisticWriteLock() throws Exception {
PreparedOperation> query = createQuery(queryMethod, r2dbcQuery, firstname, lastname);
PreparedOperationAssert.assertThat(query) //
- .selects("users.id", "users.first_name", "users.last_name", "users.date_of_birth", "users.age", "users.active") //
+ .selects("\"users\".\"id\"", "\"users\".\"first_name\"", "\"users\".\"last_name\"", "\"users\".\"date_of_birth\"", "\"users\".\"age\"", "\"users\".\"active\"") //
.from(TABLE) //
- .where("users.first_name = $1 AND (users.last_name = $2) FOR UPDATE OF users");
+ .where("\"users\".\"first_name\" = $1 AND (\"users\".\"last_name\" = $2) FOR UPDATE OF \"users\"");
}
@Test // GH-1041
@@ -747,9 +747,9 @@ void createQueryWithPessimisticReadLock() throws Exception {
PreparedOperation> query = createQuery(queryMethod, r2dbcQuery, firstname, age);
PreparedOperationAssert.assertThat(query) //
- .selects("users.id", "users.first_name", "users.last_name", "users.date_of_birth", "users.age", "users.active") //
+ .selects("\"users\".\"id\"", "\"users\".\"first_name\"", "\"users\".\"last_name\"", "\"users\".\"date_of_birth\"", "\"users\".\"age\"", "\"users\".\"active\"") //
.from(TABLE) //
- .where("users.first_name = $1 AND (users.age = $2) FOR SHARE OF users");
+ .where("\"users\".\"first_name\" = $1 AND (\"users\".\"age\" = $2) FOR SHARE OF \"users\"");
}
@Test // GH-1285
@@ -776,7 +776,7 @@ void createsQueryWithoutIdForCountProjection() throws Exception {
PreparedOperationAssert.assertThat(query) //
.selects("COUNT(1)") //
.from(TABLE) //
- .where(TABLE + ".first_name = $1");
+ .where(TABLE + ".\"first_name\" = $1");
}
@Test // GH-1310
@@ -789,7 +789,7 @@ void createsQueryWithoutIdForExistsProjection() throws Exception {
PreparedOperationAssert.assertThat(query) //
.selects("1") //
.from(TABLE) //
- .where(TABLE + ".first_name = $1 LIMIT 1");
+ .where(TABLE + ".\"first_name\" = $1 LIMIT 1");
}
private PreparedOperation> createQuery(R2dbcQueryMethod queryMethod, PartTreeR2dbcQuery r2dbcQuery,
diff --git a/spring-data-r2dbc/src/test/java/org/springframework/data/r2dbc/repository/query/R2dbcQueryMethodUnitTests.java b/spring-data-r2dbc/src/test/java/org/springframework/data/r2dbc/repository/query/R2dbcQueryMethodUnitTests.java
index b15c9b8d36..7ae04c1aec 100644
--- a/spring-data-r2dbc/src/test/java/org/springframework/data/r2dbc/repository/query/R2dbcQueryMethodUnitTests.java
+++ b/spring-data-r2dbc/src/test/java/org/springframework/data/r2dbc/repository/query/R2dbcQueryMethodUnitTests.java
@@ -67,7 +67,7 @@ void detectsCollectionFromReturnTypeIfReturnTypeAssignable() throws Exception {
RelationalEntityMetadata> metadata = queryMethod.getEntityInformation();
assertThat(metadata.getJavaType()).isAssignableFrom(Contact.class);
- assertThat(metadata.getTableName()).isEqualTo(SqlIdentifier.unquoted("contact"));
+ assertThat(metadata.getTableName()).isEqualTo(SqlIdentifier.quoted("CONTACT"));
}
@Test // gh-235
@@ -93,7 +93,7 @@ void detectsTableNameFromRepoTypeIfReturnTypeNotAssignable() throws Exception {
RelationalEntityMetadata> metadata = queryMethod.getEntityInformation();
assertThat(metadata.getJavaType()).isAssignableFrom(Address.class);
- assertThat(metadata.getTableName()).isEqualTo(SqlIdentifier.unquoted("contact"));
+ assertThat(metadata.getTableName()).isEqualTo(SqlIdentifier.quoted("CONTACT"));
}
@Test
diff --git a/spring-data-r2dbc/src/test/java/org/springframework/data/r2dbc/repository/support/SqlInspectingR2dbcRepositoryUnitTests.java b/spring-data-r2dbc/src/test/java/org/springframework/data/r2dbc/repository/support/SqlInspectingR2dbcRepositoryUnitTests.java
index 4e2a430e9f..2f505d5e71 100644
--- a/spring-data-r2dbc/src/test/java/org/springframework/data/r2dbc/repository/support/SqlInspectingR2dbcRepositoryUnitTests.java
+++ b/spring-data-r2dbc/src/test/java/org/springframework/data/r2dbc/repository/support/SqlInspectingR2dbcRepositoryUnitTests.java
@@ -85,7 +85,7 @@ private static boolean isSelect(String sql) {
}
interface MyPersonRepository extends Repository {
- @Query("select * from #{#tableName +'x'}")
+ @Query("select * from #{#tableName + 'x'}")
Mono findBySpel();
}
diff --git a/spring-data-relational/pom.xml b/spring-data-relational/pom.xml
index 8fd6d7a6f0..59e576e23d 100644
--- a/spring-data-relational/pom.xml
+++ b/spring-data-relational/pom.xml
@@ -6,7 +6,7 @@
4.0.0
spring-data-relational
- 4.0.0-SNAPSHOT
+ 4.0.0-1993-force-quoting-SNAPSHOT
Spring Data Relational
Spring Data Relational support
@@ -14,7 +14,7 @@
org.springframework.data
spring-data-relational-parent
- 4.0.0-SNAPSHOT
+ 4.0.0-1993-force-quoting-SNAPSHOT
diff --git a/spring-data-relational/src/main/java/org/springframework/data/relational/core/dialect/PostgresDialect.java b/spring-data-relational/src/main/java/org/springframework/data/relational/core/dialect/PostgresDialect.java
index a06b4e3b25..edc9600d95 100644
--- a/spring-data-relational/src/main/java/org/springframework/data/relational/core/dialect/PostgresDialect.java
+++ b/spring-data-relational/src/main/java/org/springframework/data/relational/core/dialect/PostgresDialect.java
@@ -34,6 +34,7 @@
import org.springframework.data.relational.core.sql.SimpleFunction;
import org.springframework.data.relational.core.sql.SqlIdentifier;
import org.springframework.data.relational.core.sql.TableLike;
+import org.springframework.util.Assert;
/**
* An SQL dialect for Postgres.
@@ -102,7 +103,7 @@ public LimitClause limit() {
return LIMIT_CLAUSE;
}
- private final PostgresLockClause LOCK_CLAUSE = new PostgresLockClause(this.getIdentifierProcessing());
+ private final PostgresLockClause LOCK_CLAUSE = new PostgresLockClause();
@Override
public LockClause lock() {
@@ -121,12 +122,6 @@ public Collection