Hey all,
Came back to a project I started in Redwood some time ago.
Some prisma models are using postgis coordinates. Since this isn’t supported in Prisma, I have to use the Unsupported
field and seed using raw sql, which works adequately.
I’m now wondering how to go about testing a service that uses PostGIS functionnality. Is it possible at all to use the defineScenario
function with raw sql? Or is there an alternative I’m missing?
Here’s an example model using PostGIS:
model Location {
id Int @id
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
coords Unsupported("geometry(Point, 4326)")?
@@index([coords], name: "location_idx", type: Gist)
}
and an example service with hard coded values:
export const locationsByDistance: QueryResolvers['locations'] =
() => {
return db.$queryRaw`
SELECT id,
-- other fields
ST_DistanceSphere (coords, ST_MakePoint (- 73.567253, 45.501690)) AS distance
FROM "Location"
WHERE ST_DistanceSphere (coords, ST_MakePoint (- 73.567253, 45.501690)) <= 600000
ORDER BY distance ASC
`
}
Any help would be greatly appreciated.