Open roman910dev opened 10 months ago
Same issue here! Did you find a hack to solve it?
Same issue here! Did you find a hack to solve it?
It is definitely a bug. This problem is happening because the queries with with
fail to do the fromDriver
mapping of the custom types.
I solved this problem by doing the mapping myself in the customType definition. In my case, it was a bytea
type, so for this type, I did it like this
export const bytea = customType<PgBytea>({
dataType: () => "bytea",
fromDriver: value =>
typeof value === "string"
? Buffer.from(value.slice(2), "hex")
: value,
});
I don't really understand what you are trying to do there. It does not work for me at least.
In my case, it looks like the fromDriver
call is being skipped for fields nested in with
s.
What I do as workaround is not select the column directly but instead include it in the extras
like this:
await db.query.users.findFirst({
with: {
enterprise: {
columns: {color: false},
extras: {color: sql<string>`CONCAT('#', LOWER(HEX(color)))`.as('color')}
}
}
})
What version of
drizzle-orm
are you using?0.29.0
What version of
drizzle-kit
are you using?0.20.6
Describe the Bug
I have the following custom type defined to store hex colors:
It works fine when I directly query the table:
However, when I get the table through a
with
query from another table:I have observed this behavior with other custom types too. In my case all of them are from binary columns.
Expected behavior
The expected behavior would be to get something like:
Environment & setup
No response