Hi all, i'm using Postgres + TimescaleDB and havin...
# orm-help
d
Hi all, i'm using Postgres + TimescaleDB and having trouble getting the time_bucket function to work with $queryRaw. Here is the query that is failing for me:
Copy code
const data = await this.prisma.$queryRaw(
        Prisma.sql`SELECT time_bucket('1 day'::interval, p.time::timestamptz) from prices p limit 10`,
);
I get the following error:
Copy code
Exception occured : Error in processing the request : \nInvalid `prisma.$queryRaw()` invocation:\n\n\nRaw query failed. Code: `42883`. Message: `db error: ERROR: function time_bucket(interval, timestamp with time zone) does not exist\nHINT: No function matches the given name and argument types. You might need to add explicit type casts.`"}
The same query works perfectly in my SQL editor. I've tried with and without type casts but i doesn't seem to work. Any ideas ? Thanks!
1
n
Hey David 👋 Welcome to our community! Can you try specifying the schema name in your raw query? So like instead of prices, can you try “public”.“prices” or whatever the default schema name is?
d
Thank you for the answer Nurul! Unfortunately nothing changes I get the same error message. What happens exactly when feeding a query to prisma.$queryRaw. I would have thought that it is simply sent to the sql database. Is there any sort of processing that happens? Thank you
n
As TimescaleDB is not officially supported by Prisma yet (Feature Request: #3228) I could see how there could be some potential issues like this which need addressing before we could officially announce support for it. I would recommend creating a Bug Report so that we can tackle this before announcing official support.