【发布时间】:2022-05-10 17:13:28
【问题描述】:
我想将查询转移到 TypeORM。
在 Postgres 中看起来像这样
SELECT *
from equipment_charging
where (equipment_charging."start_date"::date, equipment_charging."end_date"::date) OVERLAPS (DATE '2020-09-10', DATE '2020-09-14')
我在 TypeORM 中这样写这个查询:
.where(
'(equipment_charging.startDate::date, equipment_charging.endDate::date) OVERLAPS (DATE :startDate, DATE :endDate)',
{ startDate, endDate },
)
它给了我这样的错误:
{"context":"ExceptionsHandler","stack":["QueryFailedError: syntax error at or near \"$1\"\n at new QueryFailedError
我做错了什么?
【问题讨论】:
-
我不知道TypeORM但是尝试去掉参数前面的
DATE关键字。它仅对键入的常量值需要,但如果startDate或endDate已经是DATE实例,则不需要它们 -
非常感谢,不幸的是它没有工作......它说“\”或附近的语法错误,\“”不知道这是哪个逗号:(
标签: postgresql nestjs typeorm