fix again table column name escaping

This commit is contained in:
Marc Baloup 2019-07-18 18:26:19 +02:00
parent 4773999dd6
commit d0a80abd41
2 changed files with 2 additions and 2 deletions

View File

@ -248,7 +248,7 @@ public abstract class SQLElement<E extends SQLElement<E>> {
List<Object> psValues = new ArrayList<>();
for (Map.Entry<SQLField<E, ?>, Object> entry : modifiedValues.entrySet()) {
sql += entry.getKey().getName() + " = ? ,";
sql += "`" + entry.getKey().getName() + "` = ? ,";
addValueToSQLObjectList(psValues, entry.getKey(), entry.getValue());
}

View File

@ -36,7 +36,7 @@ public class SQLField<E extends SQLElement<E>, T> {
/* package */ Pair<String, List<Object>> forSQLPreparedStatement() {
List<Object> params = new ArrayList<>(1);
if (defaultValue != null && !autoIncrement) params.add(defaultValue);
return new Pair<>(getName() + " " + type.toString() + (canBeNull ? " NULL" : " NOT NULL")
return new Pair<>("`" + getName() + "` " + type.toString() + (canBeNull ? " NULL" : " NOT NULL")
+ (autoIncrement ? " AUTO_INCREMENT" : "")
+ ((defaultValue == null || autoIncrement) ? "" : " DEFAULT ?"), params);
}