ColumnExpress增加除法、取模表达式
This commit is contained in:
@@ -15,17 +15,25 @@ package org.redkale.source;
|
|||||||
*/
|
*/
|
||||||
public enum ColumnExpress {
|
public enum ColumnExpress {
|
||||||
/**
|
/**
|
||||||
* 直接赋值 col = val
|
* 赋值 col = val
|
||||||
*/
|
*/
|
||||||
MOV,
|
MOV,
|
||||||
/**
|
/**
|
||||||
* 追加值 col = col + val
|
* 加值 col = col + val
|
||||||
*/
|
*/
|
||||||
INC,
|
INC,
|
||||||
/**
|
/**
|
||||||
* 乘值 col = col * val
|
* 乘值 col = col * val
|
||||||
*/
|
*/
|
||||||
MUL,
|
MUL,
|
||||||
|
/**
|
||||||
|
* 除值 col = col / val
|
||||||
|
*/
|
||||||
|
DIV,
|
||||||
|
/**
|
||||||
|
* 取模 col = col % val
|
||||||
|
*/
|
||||||
|
MOD,
|
||||||
/**
|
/**
|
||||||
* 与值 col = col & val
|
* 与值 col = col & val
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -617,6 +617,22 @@ public final class EntityCache<T> {
|
|||||||
numb = numb.longValue() * ((Number) val).floatValue();
|
numb = numb.longValue() * ((Number) val).floatValue();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case DIV:
|
||||||
|
numb = (Number) attr.get(entity);
|
||||||
|
if (numb == null) {
|
||||||
|
numb = 0;
|
||||||
|
} else {
|
||||||
|
numb = numb.longValue() / ((Number) val).floatValue();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MOD:
|
||||||
|
numb = (Number) attr.get(entity);
|
||||||
|
if (numb == null) {
|
||||||
|
numb = 0;
|
||||||
|
} else {
|
||||||
|
numb = numb.longValue() % ((Number) val).intValue();
|
||||||
|
}
|
||||||
|
break;
|
||||||
case AND:
|
case AND:
|
||||||
numb = (Number) attr.get(entity);
|
numb = (Number) attr.get(entity);
|
||||||
if (numb == null) {
|
if (numb == null) {
|
||||||
|
|||||||
@@ -897,9 +897,9 @@ public final class EntityInfo<T> {
|
|||||||
/**
|
/**
|
||||||
* 字段值转换成带转义的数据库的值
|
* 字段值转换成带转义的数据库的值
|
||||||
*
|
*
|
||||||
* @param fieldname 字段名
|
* @param fieldname 字段名
|
||||||
* @param fieldvalue 字段值
|
* @param fieldvalue 字段值
|
||||||
* @param sqlFormatter 转义器
|
* @param sqlFormatter 转义器
|
||||||
*
|
*
|
||||||
* @return CharSequence
|
* @return CharSequence
|
||||||
*/
|
*/
|
||||||
@@ -911,7 +911,7 @@ public final class EntityInfo<T> {
|
|||||||
/**
|
/**
|
||||||
* 字段值转换成带转义的数据库的值
|
* 字段值转换成带转义的数据库的值
|
||||||
*
|
*
|
||||||
* @param value 字段值
|
* @param value 字段值
|
||||||
* @param sqlFormatter 转义器
|
* @param sqlFormatter 转义器
|
||||||
*
|
*
|
||||||
* @return CharSequence
|
* @return CharSequence
|
||||||
@@ -939,9 +939,9 @@ public final class EntityInfo<T> {
|
|||||||
/**
|
/**
|
||||||
* 字段值转换成带转义的数据库的值
|
* 字段值转换成带转义的数据库的值
|
||||||
*
|
*
|
||||||
* @param <F> 泛型
|
* @param <F> 泛型
|
||||||
* @param attr Attribute
|
* @param attr Attribute
|
||||||
* @param entity 记录对象
|
* @param entity 记录对象
|
||||||
* @param sqlFormatter 转义器
|
* @param sqlFormatter 转义器
|
||||||
*
|
*
|
||||||
* @return CharSequence
|
* @return CharSequence
|
||||||
@@ -1006,6 +1006,10 @@ public final class EntityInfo<T> {
|
|||||||
return new StringBuilder().append(col).append(" + ").append(val);
|
return new StringBuilder().append(col).append(" + ").append(val);
|
||||||
case MUL:
|
case MUL:
|
||||||
return new StringBuilder().append(col).append(" * ").append(val);
|
return new StringBuilder().append(col).append(" * ").append(val);
|
||||||
|
case DIV:
|
||||||
|
return new StringBuilder().append(col).append(" / ").append(val);
|
||||||
|
case MOD:
|
||||||
|
return new StringBuilder().append(col).append(" % ").append(val);
|
||||||
case AND:
|
case AND:
|
||||||
return new StringBuilder().append(col).append(" & ").append(val);
|
return new StringBuilder().append(col).append(" & ").append(val);
|
||||||
case ORR:
|
case ORR:
|
||||||
|
|||||||
Reference in New Issue
Block a user