-
I have a query that looks like the following (db is postgres): const topics = await Topic.query()
.where("user_id", user.id)
.preload("posts", (postBuilder) => {
postBuilder
.whereHas("tasks", (tasksBuilder) => {
tasksBuilder.whereRaw("DATE(completed_at) = ?", [date]);
})
.orWhereRaw("DATE(created_at) = ?", [date])
.preload("tasks", (tasksBuilder) => {
tasksBuilder.whereRaw("DATE(completed_at) = ?", [date]);
});
}); Full error:
I am under the impression that the query builder or knex or whatever is not recognizing the bind parameter placeholders, because when I change the query to this (note the single-quotes around the const topics = await Topic.query()
.where("user_id", user.id)
.preload("posts", (postBuilder) => {
postBuilder
.whereHas("tasks", (tasksBuilder) => {
tasksBuilder.whereRaw("DATE(completed_at) = '?'", [date]);
})
.orWhereRaw("DATE(created_at) = '?'", [date])
.preload("tasks", (tasksBuilder) => {
tasksBuilder.whereRaw("DATE(completed_at) = '?'", [date]);
});
}); it generates the indexed placedholders
I am doing something obviously wrong here? From what I could find the docs don't go into much more detail than
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Never mind, apparently |
Beta Was this translation helpful? Give feedback.
Never mind, apparently
Undefined binding(s)
literally meansundefined
->date
was undefined 🤦