Improved error message on missing back reference.
Closes #833 Original pull request 1384
This commit is contained in:
committed by
Jens Schauder
parent
d0a82236c6
commit
09f9da5128
@@ -260,7 +260,10 @@ class SqlGenerator {
|
||||
|
||||
Condition condition = null;
|
||||
for (SqlIdentifier backReferenceColumn : parentIdentifier.toMap().keySet()) {
|
||||
|
||||
if (SqlIdentifier.EMPTY.equals(backReferenceColumn)){
|
||||
throw new UnsupportedOperationException(
|
||||
"An empty SqlIdentifier can't be used in condition. Make sure that all composite primary keys are defined in the query.");
|
||||
}
|
||||
Condition newCondition = table.column(backReferenceColumn).isEqualTo(getBindMarker(backReferenceColumn));
|
||||
condition = condition == null ? newCondition : condition.and(newCondition);
|
||||
}
|
||||
|
||||
@@ -443,6 +443,17 @@ class SqlGeneratorUnitTests {
|
||||
|
||||
}
|
||||
|
||||
@Test // DATAJDBC-613
|
||||
void findAllByPropertyWithEmptyBackrefColumn() {
|
||||
|
||||
assertThatThrownBy(() -> {
|
||||
sqlGenerator.getFindAllByProperty(Identifier.of(EMPTY, 0, Object.class),
|
||||
unquoted("key-column"),
|
||||
false);
|
||||
}).isInstanceOf(UnsupportedOperationException.class)
|
||||
.hasMessageContaining("An empty SqlIdentifier can't be used in condition. Make sure that all composite primary keys are defined in the query.");
|
||||
}
|
||||
|
||||
@Test // DATAJDBC-219
|
||||
void updateWithVersion() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user