优化单表APIinsert接口,在驱动不支持返回主键时返回设定的主键值。

This commit is contained in:
mxd
2022-03-10 21:36:31 +08:00
parent dbad8c10ea
commit 2b73b200e4

View File

@@ -258,7 +258,11 @@ public class NamedTable extends Attributes<Object> {
builder.append(") values (");
builder.append(StringUtils.join(Collections.nCopies(entries.size(), "?"), ","));
builder.append(")");
return sqlModule.insert(new BoundSql(runtimeContext, builder.toString(), entries.stream().map(Map.Entry::getValue).collect(Collectors.toList()), sqlModule), this.primary);
Object value = sqlModule.insert(new BoundSql(runtimeContext, builder.toString(), entries.stream().map(Map.Entry::getValue).collect(Collectors.toList()), sqlModule), this.primary);
if(value == null && StringUtils.isNotBlank(this.primary)){
return this.columns.get(this.primary);
}
return value;
}
@Comment("执行delete语句")