|
38 | 38 | import org.springframework.data.jdbc.core.mapping.JdbcMappingContext;
|
39 | 39 | import org.springframework.data.relational.core.conversion.IdValueSource;
|
40 | 40 | import org.springframework.data.relational.core.dialect.AnsiDialect;
|
| 41 | +import org.springframework.data.relational.core.mapping.Column; |
41 | 42 | import org.springframework.data.relational.core.mapping.RelationalMappingContext;
|
42 | 43 | import org.springframework.data.relational.core.sql.SqlIdentifier;
|
43 | 44 | import org.springframework.jdbc.core.JdbcOperations;
|
@@ -147,6 +148,21 @@ void considersConfiguredWriteConverterForIdValueObjects_onWrite() {
|
147 | 148 | assertThat(sqlParameterSource.getValue("value")).isEqualTo(value);
|
148 | 149 | }
|
149 | 150 |
|
| 151 | + @Test // GH-1405 |
| 152 | + void parameterNamesGetSanitized() { |
| 153 | + |
| 154 | + WithIllegalCharacters entity = new WithIllegalCharacters(23L,"aValue"); |
| 155 | + |
| 156 | + SqlIdentifierParameterSource sqlParameterSource = sqlParametersFactory.forInsert(entity, WithIllegalCharacters.class, |
| 157 | + Identifier.empty(), IdValueSource.PROVIDED); |
| 158 | + |
| 159 | + assertThat(sqlParameterSource.getValue("id")).isEqualTo(23L); |
| 160 | + assertThat(sqlParameterSource.getValue("value")).isEqualTo("aValue"); |
| 161 | + |
| 162 | + assertThat(sqlParameterSource.getValue("i.d")).isNull(); |
| 163 | + assertThat(sqlParameterSource.getValue("val&ue")).isNull(); |
| 164 | + } |
| 165 | + |
150 | 166 | @WritingConverter
|
151 | 167 | enum IdValueToStringConverter implements Converter<IdValue, String> {
|
152 | 168 |
|
@@ -212,6 +228,16 @@ private static class DummyEntity {
|
212 | 228 | @Id private final Long id;
|
213 | 229 | }
|
214 | 230 |
|
| 231 | + @AllArgsConstructor |
| 232 | + private static class WithIllegalCharacters { |
| 233 | + |
| 234 | + @Column("i.d") |
| 235 | + @Id Long id; |
| 236 | + |
| 237 | + @Column("val&ue") |
| 238 | + String value; |
| 239 | + } |
| 240 | + |
215 | 241 | private SqlParametersFactory createSqlParametersFactoryWithConverters(List<?> converters) {
|
216 | 242 |
|
217 | 243 | BasicJdbcConverter converter = new BasicJdbcConverter(context, relationResolver,
|
|
0 commit comments