DATAJDBC-195 - SqlGenerator now uses upper ase key words.
This commit is contained in:
@@ -231,7 +231,7 @@ class SqlGenerator {
|
||||
}
|
||||
|
||||
private String createExistsSql() {
|
||||
return String.format("select count(*) from %s where %s = :id", entity.getTableName(), entity.getIdColumn());
|
||||
return String.format("SELECT COUNT(*) FROM %s WHERE %s = :id", entity.getTableName(), entity.getIdColumn());
|
||||
}
|
||||
|
||||
private String createCountSql() {
|
||||
@@ -240,7 +240,7 @@ class SqlGenerator {
|
||||
|
||||
private String createInsertSql(Set<String> additionalColumns) {
|
||||
|
||||
String insertTemplate = "insert into %s (%s) values (%s)";
|
||||
String insertTemplate = "INSERT INTO %s (%s) VALUES (%s)";
|
||||
|
||||
LinkedHashSet<String> columnNamesForInsert = new LinkedHashSet<>(nonIdColumnNames);
|
||||
columnNamesForInsert.addAll(additionalColumns);
|
||||
@@ -253,7 +253,7 @@ class SqlGenerator {
|
||||
|
||||
private String createUpdateSql() {
|
||||
|
||||
String updateTemplate = "update %s set %s where %s = :%s";
|
||||
String updateTemplate = "UPDATE %s SET %s WHERE %s = :%s";
|
||||
|
||||
String setClause = columnNames.stream()//
|
||||
.map(n -> String.format("%s = :%s", n, n))//
|
||||
@@ -263,7 +263,7 @@ class SqlGenerator {
|
||||
}
|
||||
|
||||
private String createDeleteSql() {
|
||||
return String.format("DELETE from %s where %s = :id", entity.getTableName(), entity.getIdColumn());
|
||||
return String.format("DELETE FROM %s WHERE %s = :id", entity.getTableName(), entity.getIdColumn());
|
||||
}
|
||||
|
||||
String createDeleteAllSql(PropertyPath path) {
|
||||
|
||||
@@ -58,7 +58,7 @@ public class DefaultDataAccessStrategyUnitTests {
|
||||
|
||||
accessStrategy.insert(new DummyEntity(ORIGINAL_ID), DummyEntity.class, additionalParameters);
|
||||
|
||||
verify(jdbcOperations).update(eq("insert into DummyEntity (id) values (:id)"), paramSourceCaptor.capture(),
|
||||
verify(jdbcOperations).update(eq("INSERT INTO DummyEntity (id) VALUES (:id)"), paramSourceCaptor.capture(),
|
||||
any(KeyHolder.class));
|
||||
}
|
||||
|
||||
@@ -74,8 +74,8 @@ public class DefaultDataAccessStrategyUnitTests {
|
||||
verify(jdbcOperations).update(sqlCaptor.capture(), paramSourceCaptor.capture(), any(KeyHolder.class));
|
||||
|
||||
assertThat(sqlCaptor.getValue()) //
|
||||
.containsSequence("insert into DummyEntity (", "id", ") values (", ":id", ")") //
|
||||
.containsSequence("insert into DummyEntity (", "reference", ") values (", ":reference", ")");
|
||||
.containsSequence("INSERT INTO DummyEntity (", "id", ") VALUES (", ":id", ")") //
|
||||
.containsSequence("INSERT INTO DummyEntity (", "reference", ") VALUES (", ":reference", ")");
|
||||
assertThat(paramSourceCaptor.getValue().getValue("id")).isEqualTo(ORIGINAL_ID);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user