This commit is contained in:
@@ -937,13 +937,13 @@ public abstract class DataSqlSource<DBChannel> extends AbstractService implement
|
||||
Attribute<T, Serializable> attr = info.getUpdateAttribute(col.getColumn());
|
||||
if (attr == null) throw new RuntimeException(info.getType() + " cannot found column " + col.getColumn());
|
||||
if (setsql.length() > 0) setsql.append(", ");
|
||||
String c = info.getSQLColumn(null, col.getColumn());
|
||||
String sqlColumn = info.getSQLColumn(null, col.getColumn());
|
||||
if (col.getValue() instanceof byte[]) {
|
||||
if (blobs == null) blobs = new ArrayList<>();
|
||||
blobs.add((byte[]) col.getValue());
|
||||
setsql.append(c).append(" = ").append(prepareParamSign(++index));
|
||||
setsql.append(sqlColumn).append(" = ").append(prepareParamSign(++index));
|
||||
} else {
|
||||
setsql.append(c).append(" = ").append(info.formatSQLValue(c, attr, col, sqlFormatter));
|
||||
setsql.append(sqlColumn).append(" = ").append(info.formatSQLValue(sqlColumn, attr, col, sqlFormatter));
|
||||
}
|
||||
}
|
||||
if (setsql.length() < 1) return CompletableFuture.completedFuture(0);
|
||||
@@ -1019,13 +1019,13 @@ public abstract class DataSqlSource<DBChannel> extends AbstractService implement
|
||||
Attribute<T, Serializable> attr = info.getUpdateAttribute(col.getColumn());
|
||||
if (attr == null) continue;
|
||||
if (setsql.length() > 0) setsql.append(", ");
|
||||
String c = info.getSQLColumn(alias, col.getColumn());
|
||||
String sqlColumn = info.getSQLColumn(alias, col.getColumn());
|
||||
if (col.getValue() instanceof byte[]) {
|
||||
if (blobs == null) blobs = new ArrayList<>();
|
||||
blobs.add((byte[]) col.getValue());
|
||||
setsql.append(c).append(" = ").append(prepareParamSign(++index));
|
||||
setsql.append(sqlColumn).append(" = ").append(prepareParamSign(++index));
|
||||
} else {
|
||||
setsql.append(c).append(" = ").append(info.formatSQLValue(c, attr, col, sqlFormatter));
|
||||
setsql.append(sqlColumn).append(" = ").append(info.formatSQLValue(sqlColumn, attr, col, sqlFormatter));
|
||||
}
|
||||
}
|
||||
if (setsql.length() < 1) return CompletableFuture.completedFuture(0);
|
||||
|
||||
@@ -989,31 +989,31 @@ public final class EntityInfo<T> {
|
||||
/**
|
||||
* 拼接UPDATE给字段赋值的SQL片段
|
||||
*
|
||||
* @param col 表字段名
|
||||
* @param sqlColumn 表字段名
|
||||
* @param attr Attribute
|
||||
* @param cv ColumnValue
|
||||
* @param formatter 转义器
|
||||
*
|
||||
* @return CharSequence
|
||||
*/
|
||||
protected CharSequence formatSQLValue(String col, Attribute<T, Serializable> attr, final ColumnValue cv, BiFunction<EntityInfo, Object, CharSequence> formatter) {
|
||||
protected CharSequence formatSQLValue(String sqlColumn, Attribute<T, Serializable> attr, final ColumnValue cv, BiFunction<EntityInfo, Object, CharSequence> formatter) {
|
||||
if (cv == null) return null;
|
||||
Object val = cv.getValue();
|
||||
CryptHandler handler = attr.attach();
|
||||
if (handler != null) val = handler.encrypt(val);
|
||||
switch (cv.getExpress()) {
|
||||
case INC:
|
||||
return new StringBuilder().append(col).append(" + ").append(val);
|
||||
return new StringBuilder().append(sqlColumn).append(" + ").append(val);
|
||||
case MUL:
|
||||
return new StringBuilder().append(col).append(" * ").append(val);
|
||||
return new StringBuilder().append(sqlColumn).append(" * ").append(val);
|
||||
case DIV:
|
||||
return new StringBuilder().append(col).append(" / ").append(val);
|
||||
return new StringBuilder().append(sqlColumn).append(" / ").append(val);
|
||||
case MOD:
|
||||
return new StringBuilder().append(col).append(" % ").append(val);
|
||||
return new StringBuilder().append(sqlColumn).append(" % ").append(val);
|
||||
case AND:
|
||||
return new StringBuilder().append(col).append(" & ").append(val);
|
||||
return new StringBuilder().append(sqlColumn).append(" & ").append(val);
|
||||
case ORR:
|
||||
return new StringBuilder().append(col).append(" | ").append(val);
|
||||
return new StringBuilder().append(sqlColumn).append(" | ").append(val);
|
||||
case MOV:
|
||||
return formatter == null ? formatToString(val) : formatter.apply(this, val);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user