escaping column names in ORM
This commit is contained in:
parent
e9188b8c1a
commit
4773999dd6
@ -41,7 +41,7 @@ public class SQLOrderBy {
|
|||||||
for (OBField f : orderByFields) {
|
for (OBField f : orderByFields) {
|
||||||
if (!first) ret += ", ";
|
if (!first) ret += ", ";
|
||||||
first = false;
|
first = false;
|
||||||
ret += f.field.getName() + " " + f.direction.name();
|
ret += "`" + f.field.getName() + "` " + f.direction.name();
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,8 @@ public class SQLWhereChain extends SQLWhere {
|
|||||||
|
|
||||||
public enum SQLBoolOp {
|
public enum SQLBoolOp {
|
||||||
/** Equivalent to SQL "<code>AND</code>" */
|
/** Equivalent to SQL "<code>AND</code>" */
|
||||||
AND("AND"), /** Equivalent to SQL "<code>OR</code>" */
|
AND("AND"),
|
||||||
|
/** Equivalent to SQL "<code>OR</code>" */
|
||||||
OR("OR");
|
OR("OR");
|
||||||
public final String sql;
|
public final String sql;
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ public class SQLWhereComp extends SQLWhere {
|
|||||||
public Pair<String, List<Object>> toSQL() throws ORMException {
|
public Pair<String, List<Object>> toSQL() throws ORMException {
|
||||||
List<Object> params = new ArrayList<>();
|
List<Object> params = new ArrayList<>();
|
||||||
SQLElement.addValueToSQLObjectList(params, left, right);
|
SQLElement.addValueToSQLObjectList(params, left, right);
|
||||||
return new Pair<>(left.getName() + " " + comp.sql + " ? ", params);
|
return new Pair<>("`" + left.getName() + "` " + comp.sql + " ? ", params);
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum SQLComparator {
|
public enum SQLComparator {
|
||||||
|
@ -27,7 +27,7 @@ public class SQLWhereLike extends SQLWhere {
|
|||||||
public Pair<String, List<Object>> toSQL() {
|
public Pair<String, List<Object>> toSQL() {
|
||||||
ArrayList<Object> params = new ArrayList<>();
|
ArrayList<Object> params = new ArrayList<>();
|
||||||
params.add(likeExpr);
|
params.add(likeExpr);
|
||||||
return new Pair<>(field.getName() + " LIKE ? ", params);
|
return new Pair<>("`" + field.getName() + "` LIKE ? ", params);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ public class SQLWhereNull extends SQLWhere {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Pair<String, List<Object>> toSQL() {
|
public Pair<String, List<Object>> toSQL() {
|
||||||
return new Pair<>(fild.getName() + ((nulll) ? " IS NULL" : " IS NOT NULL"), new ArrayList<>());
|
return new Pair<>("`" + fild.getName() + "` IS " + ((nulll) ? "NULL" : "NOT NULL"), new ArrayList<>());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user