Prisma 不等于 true,过滤不正确

发布于 2025-01-19 20:08:06 字数 496 浏览 2 评论 0原文

如下所示,我正在运行Prisma Postgres过滤器查询。但是,当我添加不等于过滤器时,它最终会过滤所有内容并没有返回结果,而不会出错。我在做什么错?我有各种各样的条目,两个is_soundtrack false,true和null。所以我应该得到一些结果。我还评论了另一种使用不是的方法,但是这也不起作用?

我想显示所有结果,其中IS_SOUNDTRACK不等于true。

const songs = await this.db.song.findMany({
  where: {
    name: {
      contains: "test string,
    },
    // is_soundtrack: {
    //   not: true,
    // },
    NOT: {
      is_soundtrack: true,
    },
  },
  orderBy: {
    spotifyImg640: 'desc',
  }
})

I'm running a prisma postgres filter query, as below. However when I add the NOT equal to filter, it ends up filtering everything and returning no results, without an error. What am I doing wrong? I have a variety of entries with both is_soundtrack false, true and null. So I should be getting some results. I also commented out another approach to using NOT, however this also doesn't work?

I'm wanting to show all results, where is_soundtrack does not equal true.

const songs = await this.db.song.findMany({
  where: {
    name: {
      contains: "test string,
    },
    // is_soundtrack: {
    //   not: true,
    // },
    NOT: {
      is_soundtrack: true,
    },
  },
  orderBy: {
    spotifyImg640: 'desc',
  }
})

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

过潦 2025-01-26 20:08:06

prisma将iSNOT:true转换为其中column<> true不起作用。

这就是我要做的:

await prisma.questions.findMany({
    where: { OR: [{ keepHidden: false }, { keepHidden: null }] }
})

Prisma converts isNot: true to where column <> true which does not work.

This is what I had to do:

await prisma.questions.findMany({
    where: { OR: [{ keepHidden: false }, { keepHidden: null }] }
})
執念 2025-01-26 20:08:06

我想显示所有结果,其中IS_SOUNDTRACK不等于true。

因此,您需要:

is_soundtrack IS NOT TRUE

或:

is_soundtrack IS DISTINCT FROM true

或:

(is_soundtrack = false OR is_soundtrack IS NULL)

当前过滤器不是IS_SOUNDTRACK = true只能覆盖false,而是排除空值。

在此处阅读手册。

I'm wanting to show all results, where is_soundtrack does not equal true.

So you need:

is_soundtrack IS NOT TRUE

Or:

is_soundtrack IS DISTINCT FROM true

Or:

(is_soundtrack = false OR is_soundtrack IS NULL)

The current filter NOT is_soundtrack = true would only cover false, but exclude null values.

Read the manual here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文