Custom Type interpreted as String

Hello everyone, I am having some issues with getting Drizzle to work with PostGIS, I am trying to have support for PostGIS's Point geometry. This is what I have setup

export type Point = {
    longitude: number;
    latitude: number;
};

export const pointDB = customType<
    {
        data: Point;
        driverData: string;
    }
>({
    dataType() {
        return 'GEOMETRY(POINT, 4326)';
    },
    toDriver(value: Point): string {
        return `SRID=4326;POINT(${value.longitude} ${value.latitude})`;
    },
    fromDriver(value: string): Point {
        const matches = value.match(/POINT\((?<longitude>[\d.-]+) (?<latitude>[\d.-]+)\)/);
        const { longitude, latitude } = matches.groups;

        return {
            longitude: parseFloat(longitude),
            latitude: parseFloat(latitude),
        };
    },
});


But the data returned stays a string

carriers: Array(1)0: 
id: "db34d18d-b4d0-42e2-8121-29d47ad18327"
location: "POINT(44.769368 20.4631)"


This is my query
const carriers = await db.select({
    id: activeCarriers.employeeId,
    location: sql<Point>`st_astext(active_carriers.location) as location`,
    })
    .from(activeCarriers)
return { carriers }


This is happening across packages in monorepo, not sure if that could cause the type inference to fail
Was this page helpful?