Open Odas0R opened 10 months ago
Just figured out that if I cast it to json, there's a JSON.parse being done? Confused, maybe this might not be a bug.
// This works
extras: {
polygon: sql`ST_AsGeoJSON(${polygon.geometry})::json`
.mapWith(polygon.geometry)
.as("polygon"),
centroid: sql`ST_AsGeoJSON(${polygon.centroid})::json`
.mapWith(polygon.centroid)
.as("centroid"),
}
Still the fromDriver
is not being executed on the example above? I'm a bit confused.
I'm noticing that decoders on sql statements that are part of subqueries aren't being executed - I'm wondering if that's related?
I think I have the same issue. For example, a program
table that has many(student)
:
const res = await db.query.program.findMany({
extras: {
studentsCount: sql<number>`(select count(*) from student s where s.program_id = program.id)`
.mapWith(Number)
.as("students_count")
}
});
studentsCount is always returning as a string.
What version of
drizzle-orm
are you using?0.28.5
What version of
drizzle-kit
are you using?0.19.13
Describe the Bug
The
mapWith
isn't executing thefromDriver
callback on the custom type:Expected behavior
It should parse the value received from the driver, as for now I fix the result with custom hacks.
Environment & setup
NODE: 16.19.1 POP_os: 22.04