I'm having an issue with queryRaw, where my date i...
# orm-help
j
I'm having an issue with queryRaw, where my date is returning as a string. Am I doing something wrong? • Column defined like
effectiveDate  DateTime? @map("effective_date") @db.Date
• Query looks like
Copy code
const courses: Course[] = await prisma.$queryRaw<Course[]>`
    SELECT
      id,
      course_number,
      effective_date as "effectiveDate",
      ....
But if I try and do effectiveDate.getDate() or something, I get a runtime error; and if I console.log
typeof effectiveDate
, it tells me that it's a string. If I do my query using
prisma.findMany
, it works fine. I do see in the docs it says
Type caveats when using raw SQL: When you type the results of $queryRaw, the raw data does not always match the suggested TypeScript type.
So, is it expected behavior that the date returns as a string, or am I doing something wrong? And if it matters,
prisma --version
gives me
Copy code
prisma                  : 3.0.1
@prisma/client          : 3.7.0
Current platform        : windows