Description

gorm: v1.22.5; not happen in v1.22.4 mysql

=> AND user_invitations.id

=== RUN   TestDeleteUserInvitation
2022/02/03 16:05:46 [] &{Model:{Id:1 CreatedAt:0001-01-01 00:00:00 +0000 UTC UpdatedAt:0001-01-01 00:00:00 +0000 UTC DeletedAt:<nil>} UserId:0 User:<nil> Token: UserRoleId:0 UserRole:<nil> Name: Email: Company:<nil> Expire:0001-01-01 00:00:00 +0000 UTC Accepted:false PaymentMethodId:<nil> PaymentMethod:<nil> UserInvitationAddressId:<nil> UserInvitationAddress:<nil>}

2022/02/03 16:05:46 /Users/lucasloffel/go/src/github.com/ranked-de/ranked-api/database/repository/user_invitation.go:102 ExecQuery 'UPDATE `user_invitations` SET `deleted_at`=? WHERE (user_invitations.expire >= ? AND user_invitations.accepted = ?) AND `user_invitations`.`id` = ? AND `user_invitations`.`id` = ? AND `user_invitations`.`deleted_at` IS NULL', arguments do not match: expected 4, but got 5 arguments; call to Rollback transaction, was not expected, next expectation is: ExpectedExec => expecting Exec or ExecContext which:
  - matches sql: 'UPDATE `user_invitations`'
  - is with arguments:
    0 - {}
    1 - {}
    2 - false
    3 - 1
  - should return Result having:
      LastInsertId: 0
      RowsAffected: 1
// DeleteUserInvitation deletes user invitation
func (repository *UserInvitationRepository) DeleteUserInvitation(connection *gorm.DB, userInvitation *model.UserInvitation, filters []filter.Filter) error {
    var query = repository.activeUserInvitation(connection)

    for _, tmpFilter := range filters {
        query = tmpFilter.GetQuery(query)
    }

    log.Printf("%+v %+v", filters, userInvitation)

    return query.
        Delete(userInvitation).
        Error
}

func (repository *UserInvitationRepository) activeUserInvitation(query *gorm.DB) *gorm.DB {
    return query.Where("user_invitations.expire >= ? AND user_invitations.accepted = ?", time.Now(), false)
}

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 2 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: li-jin-gou

hello @loeffel-io can you provide a demo in https://github.com/go-gorm/playground ? thanks

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 2 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