Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

findUnique not excluding when compound key is used #5

Open
Georgegriff opened this issue Nov 20, 2023 · 1 comment
Open

findUnique not excluding when compound key is used #5

Georgegriff opened this issue Nov 20, 2023 · 1 comment

Comments

@Georgegriff
Copy link

Georgegriff commented Nov 20, 2023

Thank you for this amazing library!

I have a work around for this issue but I thought i'd post to check if there is a potential bug:

I'd expect to not have to specify deletedAt

Example not working

  const collaboration = await ctx.prisma.collaborator.findUnique({
    where: {
      userId_planId: {
        userId: userId,
        planId: planId,
      },
    },
    select: {
      planAccessType: true,
    },
  });

It works when i do this

  const collaboration = await ctx.prisma.collaborator.findUnique({
    where: {
      userId_planId: {
        userId: userId,
        planId: planId,
      },
      deletedAt: null,
    },
    select: {
      planAccessType: true,
    },
  });

Here is my configuration:

  const extendedClient = client.$extends(
    createSoftDeleteExtension({
      models: {
        Collaborator: true,
      },
      defaultConfig: {
        field: "deletedAt",
        createValue: (deleted) => {
          if (deleted) return new Date();
          return null;
        },
      },
    })
  );
@olivierwilkinson
Copy link
Owner

Hi there,

Thank you for raising this! It's quite likely I need to add a special case for this, I'll look into it soon 😄

I'm glad you are finding the library helpful! Please let me know if you find any other issues or have any feedback 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants