Vjau
Vjau
KKysely
Created by Vjau on 1/18/2025 in #help
could not determine data type of parameter $1
I am trying to nest PG functions array_agg and json_build_object I tried like this
select(({ fn, eb, val }) => {
return fn
.agg<
{
foo_col: string;
bar_col:string;
}[]
>("array_agg", [
eb.fn("json_build_object", [
val("foo_col"),
"sometable.foo",
val("bar_col"),
"sometable.bar",
]),
])
.as("objs")
select(({ fn, eb, val }) => {
return fn
.agg<
{
foo_col: string;
bar_col:string;
}[]
>("array_agg", [
eb.fn("json_build_object", [
val("foo_col"),
"sometable.foo",
val("bar_col"),
"sometable.bar",
]),
])
.as("objs")
However, i receive an error from Postgres could not determine data type of parameter $1 Looking at the compiled query, val("foo_col") seems to be replaced by $1 then applied as first param. Why are val values parameterized since they are pretty much static ? Why is postgres complaining about the type thing ? Thank you.
4 replies