#.update return null when data is found using .findUnique using the same where clause (version 5.17.

5 messages · Page 1 of 1 (latest)

scarlet marlin
#

How is this even possible ?
my updatedUser is null, and no updated has been performed
But the data exist since the user is found successfully

no error is thrown by prisma just updatedUser being null

with console loggin User not found or update failed transactionId

      where: {
        something: xxx,
        userId,
      },
    });

if (!userFound) {
      this.logger.log(
        `userFound not found`,
      );
      return null;
    }

    this.logger.debug('User found');

const updatedUser = await this.db.users.update({
      where: {
        something: xxx,
        userId,
      },
      data: {
        name,
        alias,
      },
    });

    if (!updatedUser) {
      this.logger.log(
        `User not found or update failed transactionId`,
      );
      return null;
    }

#

<@&937755430136995890> @brave sail @severe swan
Would love to get your thoughts on this puzzle
Been using prisma for 2 years now, and first time not being able to understand this issue

tight zenith
#

I had the same issue before. Solved using AND operator in both queries.

tight zenith
#

BTW, set export DEBUG="*" and you could see query differences by yourself.

scarlet marlin