is there a way to wrap a column select with ST_AsText or any other sql statement?
I've created a custom column type but the column return by default a binary data, instead i want to wrap the select automatically with ST_AsText to human readable text.
7 Replies
Yes, you can use the magic sql operator: https://orm.drizzle.team/docs/sql#sql-select
Magical sql operator 🪄 - DrizzleORM
Drizzle ORM | %s
@Angelelz you mind giving me a hint over here? this is my custom type:
i'm trying the default select of this field to be
ST_AsText(
<colum-type>) as PointText
I think this is what you're looking for:
I think, I'm just not familiar with this data type
@Angelelz i gave it a try but I think toDriver only happen on executions (insert,update,etc) for query it just uses the default select (select: <column-name>)
here is my try:
You're absolutely right, my bad. There's an open issue for this feature: https://github.com/drizzle-team/drizzle-orm/issues/1083
GitHub
[FEATURE]: Default select for custom types · Issue #1083 · drizzle-...
Describe what you want When creating a custom type that doesn't have a straightforward select like a postgis geometry, for example. export type Point = { lat: number; lng: number; }; export con...
This is not implemented yet.
So you're going to have to do:
On every select
yes i saw it, problem you can't do it with query so it's kinda annoying