//插入数据的代码:

 //手动分表创建
    return db.Instance().Transaction(func(tx *gorm.DB) error {
        // 使用 'tx' 而不是 'db'
        info.Status = "C" //初始化状态
        //取消所有关联创建!
        if err := tx.Omit(clause.Associations).Create(info).Error; err != nil {
            // 返回任何错误都会回滚事务
            return err
        }
        for i := range info.MesFormulaList {
            info.MesFormulaList[i].FormulaId = info.Id
        }
        if err := tx.Model(&AppDbModel.MesFormulaList{}).Create(info.MesFormulaList).Error; err != nil {
            // 返回任何错误都会回滚事务
            return err
        }

        return nil
    })

//查询数据的代码

//手动分表创建
    return db.Instance().Transaction(func(tx *gorm.DB) error {
        // 使用 'tx' 而不是 'db'
        info.Status = "C" //初始化状态
        //取消所有关联创建!
        if err := tx.Omit(clause.Associations).Create(info).Error; err != nil {
            // 返回任何错误都会回滚事务
            return err
        }
        for i := range info.MesFormulaList {
            info.MesFormulaList[i].FormulaId = info.Id
        }
        if err := tx.Model(&AppDbModel.MesFormulaList{}).Create(info.MesFormulaList).Error; err != nil {
            // 返回任何错误都会回滚事务
            return err
        }

        return nil
    })

插入后,马上查询查不到,但是再插入一条,上一次插入的就能找到!!!!

Comment From: github-actions[bot]

The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking

Comment From: dk-lockdown

@chun222 have you been solve this problem?