updateMany crashes when updating role at up.users

System Information
  • Strapi Version: 4.12.5
  • Operating System: ubuntu 20.04
  • Database: mysql 8

I might have found a bug while bulk updating the users.

I am running the following code in a cron task:

const result = await strapi.db
      .query("plugin::users-permissions.user")
      .updateMany({
        where: {
          role: { id: { $eq: premiumId } },
          subscription_end_at: { $lt: myDate },
        },
        data: { role: authenticatedId },
      });

It is throwing an error saying: ‘Update requires data’, but actually I am sending data. So I started debugging and I saw that data is ok, but the function updateMany is calling processData and processData is returning an empty object.

Then at processData I saw this line: if (attribute.joinColumn && ...). As you can see in the image below, the user.role attribute does not have a joinColumn, but it has a joinTable.joinColumn.

So… Maybe it should be getting the information from there? Maybe this is really a bug while combining updateMany with up-users and updating the role?

Thank you!