We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
func (d *dao) UpdateGridValue(ctx context.Context, gridKey string, req *model.UpdateV) (err error) { c := d.mongo.Database(dbname).Collection(gridKey) filter := bson.M{"index": req.I, "celldata": bson.M{"$elemMatch": bson.M{"r": req.R, "c": req.C}}} formatV, err := d.format2Bson(req.V) if err != nil { log.With("err", err).With("v", req.V).Errorln("format2bson error") return } res, err := c.UpdateOne(ctx, filter, bson.D{{"$set", bson.D{{"celldata.$.v", formatV}}}}) if err != nil { log.With("err", err).With("gridKey", gridKey).With("req", req).Errorln("update error") return } if res.ModifiedCount <= 0 { formatCell, err := d.format2Bson(req.Cell) if err != nil { log.With("err", err).With("cell", req.Cell).Errorln("format2bson error") return err } _, err = c.UpdateOne(ctx, bson.M{"index": req.I}, bson.M{"$push": bson.M{"celldata": formatCell}}) } return err } mongo.go:第171行这个地方 应该以匹配行数是否大于0来判断该sheet是否有这个单元格 现有的逻辑在批量设置格式时(rv操作)部分v值完全没有变化时,res.ModifiedCount就是0了,但matchedCount是1, 这个时候按现有代码逻辑 就会push一条新的数据到celldata中,最终导致celldata中同一个单元格有两个值
func (d *dao) UpdateGridValue(ctx context.Context, gridKey string, req *model.UpdateV) (err error) { c := d.mongo.Database(dbname).Collection(gridKey) filter := bson.M{"index": req.I, "celldata": bson.M{"$elemMatch": bson.M{"r": req.R, "c": req.C}}} formatV, err := d.format2Bson(req.V) if err != nil { log.With("err", err).With("v", req.V).Errorln("format2bson error") return } res, err := c.UpdateOne(ctx, filter, bson.D{{"$set", bson.D{{"celldata.$.v", formatV}}}}) if err != nil { log.With("err", err).With("gridKey", gridKey).With("req", req).Errorln("update error") return } if res.ModifiedCount <= 0 { formatCell, err := d.format2Bson(req.Cell) if err != nil { log.With("err", err).With("cell", req.Cell).Errorln("format2bson error") return err } _, err = c.UpdateOne(ctx, bson.M{"index": req.I}, bson.M{"$push": bson.M{"celldata": formatCell}}) } return err }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
func (d *dao) UpdateGridValue(ctx context.Context, gridKey string, req *model.UpdateV) (err error) { c := d.mongo.Database(dbname).Collection(gridKey) filter := bson.M{"index": req.I, "celldata": bson.M{"$elemMatch": bson.M{"r": req.R, "c": req.C}}} formatV, err := d.format2Bson(req.V) if err != nil { log.With("err", err).With("v", req.V).Errorln("format2bson error") return } res, err := c.UpdateOne(ctx, filter, bson.D{{"$set", bson.D{{"celldata.$.v", formatV}}}}) if err != nil { log.With("err", err).With("gridKey", gridKey).With("req", req).Errorln("update error") return } if res.ModifiedCount <= 0 { formatCell, err := d.format2Bson(req.Cell) if err != nil { log.With("err", err).With("cell", req.Cell).Errorln("format2bson error") return err } _, err = c.UpdateOne(ctx, bson.M{"index": req.I}, bson.M{"$push": bson.M{"celldata": formatCell}}) } return err }
mongo.go:第171行这个地方 应该以匹配行数是否大于0来判断该sheet是否有这个单元格
现有的逻辑在批量设置格式时(rv操作)部分v值完全没有变化时,res.ModifiedCount就是0了,但matchedCount是1,
这个时候按现有代码逻辑 就会push一条新的数据到celldata中,最终导致celldata中同一个单元格有两个值
The text was updated successfully, but these errors were encountered: