drizzle-team / drizzle-team/drizzle-orm
[BUG] toDriver method never been called on customType
- Dominant language
- TypeScript
- Stars
- 35.8k
- Forks
- 1.6k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 4
Description
### What version of `drizzle-orm` are you using?
0.30.8
### What version of `drizzle-kit` are you using?
0.20.10
### Describe the Bug
[Context] I have an application where I will change the database type. [mongo -> postgresql] So until that point, I'm using [Mongo FWD](https://github.com/EnterpriseDB/mongo_fdw) to keep data synced between databases and multiple services.
So I have to use the `customType` function from drizzle-orm/pg-core and I defined the `toDriver` method to convert values. I have to cover cases when the incoming value is null, and I have to convert it here because of the type differences.
And I realized even if I define a method to convert data, when I'm inserting, the toDriver is never called if the value is `null`.
https://github.com/drizzle-team/drizzle-orm/blob/3bbf9ed5f4e5ec6b1fa6f303714ad02bd98f6b6e/drizzle-orm/src/sql/sql.ts#L206C1-L207C1
For me, it seems logical that if the `toDriver` is defined, then it should be called whatever the value is because it's created on purpose.
### Expected behavior
If the toDriver method is defined on a customType, then it has to be called with any type of value.
### Environment & setup
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.