title: Gorm Association Replace condition is not working with where clause and omit() function
body: <p>Gorm Association Replace condition is not working with where clause and omit() function</p>
  <pre><code>func (u *userEnitity) EditUser(emplyeeCode string, user models.User) (models.User, int, string) {
          var tx *gorm.DB
          var statusCode = 200
          var errText string
          var count int64
          var id int
          var roleId []int
          count = 0
          if tx = u.resource.Select(&quot;id&quot;).Model(&amp;models.User{}).Where(&quot;employee_code = ? &quot;, emplyeeCode).Scan(&amp;id).Count(&amp;count); tx.Error != nil {
              return user, statusCode, errText
          }
          if count == 0 {
      
              return user, 400, &quot;User does not exist&quot;
          }
      
          u.resource.Debug().Model(&amp;models.User{}).Where(&quot;id = ?&quot;, id).Updates(models.User{
              FirstName:  user.FirstName,
              MiddleName: user.MiddleName,
              LastName:   user.LastName,
              MobileNo:   user.MobileNo,
              Email:      user.Email,
          })
          if tx = u.resource.Table(&quot;user_role&quot;).Select(&quot;role_id&quot;).Where(&quot;user_id = ?&quot;, id).Scan(&amp;roleId); tx.Error != nil {
              return user, statusCode, errText
          }
      
          u.resource.Debug().Model(&amp;user).Where(&quot;id =  ?&quot;,roleId).Omit(&quot;user_role&quot;).Association(&quot;Roles&quot;).Replace(&amp;user.Roles)
          return user, statusCode, errText
      }
  </code></pre>