首页 > 解决方案 > Prisma 2 无法获取具有空值的 DateTime 列

问题描述

      await this.prisma.fee_collections.findMany({
        where: whereClauseWithTransactionDateCondition,
        include: {
            student_master: {
                select: {
                    fee_start_month: true,
                }
            }
        }
    });

在我的数据库中, fee_start_month 列架构:

fee_start_month 日期时间?@db.日期

在 fee_start_month 列中,一些值为空,因此 prisma2 无法获取这些记录,并引发异常。

生成的错误:[Nest] 21275 - 2021 年 3 月 15 日,13:09:21 [ExceptionsHandler] 无效prisma.fee_collections.findMany()调用:

值超出类型的范围。该列fee_start_month包含无效的 DateTime 值,其中日或月设置为零。+3337 毫秒

标签: prisma2

解决方案


推荐阅读