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