Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FieldMatcher lock&actived 逻辑存在bug,不识别@Column hump& value 定义的alias #1579

Open
xraylee opened this issue May 28, 2021 · 1 comment

Comments

@xraylee
Copy link

xraylee commented May 28, 2021

BEAN 定义如下:
@table("coin_activity")
public class CoinActivityDO extends BaseDO {

private static final long serialVersionUID = -3645547428797953987L;

/**
 * 关联的优惠ID
 */
@Column(hump = true)
private Long refPromotionId;

/**
 * 所属卖家ID
 */
@Column(hump = true)
private Long sellerId;

}

我需要忽略更新sellerId字段,设置的update脚本如下:

Condition condition = Cnd.where("id", "=", coinActivityDO.getId()).and("seller_id", "=", coinActivityDO.getSellerId())
.and("venture", "=", coinActivityDO.getVenture());
//注意lock函数有bug
Chain chain = Chain.from(coinActivityDO, FieldMatcher.make(null, "seller_id", true));
return coinActivityDao.updateInstance(CoinActivityDO.class, chain, condition);

实际跟踪到忽略逻辑如下 org.nutz.dao.Chain line 222:
Mirror<?> mirror = Mirror.me(obj.getClass());
for (Field f : mirror.getFields()) {
//此处仅识别Field name, 未识别@column注解定义的hump& value alias别称
if (null != fm && !fm.match(f.getName()))
continue;
Object v = mirror.getValue(obj, f.getName());
if (null == v) {
if (fm != null && fm.isIgnoreNull())
continue;
} else if (fm != null && fm.isIgnoreBlankStr() && v instanceof String && Strings.isBlank((String)v)) {
continue;
}
if (c == null) {
c = Chain.make(f.getName(), v);
} else {
c = c.add(f.getName(), v);
}
}

@happyday517
Copy link
Contributor

算不上bug,用sellerId应该是可以的吧?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants