From d0a80abd41654bce90200038af74e7e40cc61ab6 Mon Sep 17 00:00:00 2001 From: Marc Baloup Date: Thu, 18 Jul 2019 18:26:19 +0200 Subject: [PATCH] fix again table column name escaping --- src/main/java/fr/pandacube/java/util/orm/SQLElement.java | 2 +- src/main/java/fr/pandacube/java/util/orm/SQLField.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/fr/pandacube/java/util/orm/SQLElement.java b/src/main/java/fr/pandacube/java/util/orm/SQLElement.java index 6bdb669..15b0a46 100644 --- a/src/main/java/fr/pandacube/java/util/orm/SQLElement.java +++ b/src/main/java/fr/pandacube/java/util/orm/SQLElement.java @@ -248,7 +248,7 @@ public abstract class SQLElement> { List psValues = new ArrayList<>(); for (Map.Entry, Object> entry : modifiedValues.entrySet()) { - sql += entry.getKey().getName() + " = ? ,"; + sql += "`" + entry.getKey().getName() + "` = ? ,"; addValueToSQLObjectList(psValues, entry.getKey(), entry.getValue()); } diff --git a/src/main/java/fr/pandacube/java/util/orm/SQLField.java b/src/main/java/fr/pandacube/java/util/orm/SQLField.java index 8f7fb01..154678b 100644 --- a/src/main/java/fr/pandacube/java/util/orm/SQLField.java +++ b/src/main/java/fr/pandacube/java/util/orm/SQLField.java @@ -36,7 +36,7 @@ public class SQLField, T> { /* package */ Pair> forSQLPreparedStatement() { List 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); }