Replies: 1 comment 7 replies
-
The problem here is that May I ask why are you even trying to do this? Why not use the type that is expected here instead of bigint (which is surely meant for something else than timestamps). Both timestamptz and bigint will take 8 bytes of storage, so its not like you would spare some storage size by doing this. And I am rather sure that dates are technically stored as timestamps (numbers) in the actual storage. Btw it works with sqlite since there is no native bigint type, the value is stored as a number (which works with I will try to think of some workaround, 6.2.5 introduced an option to explicitly specify the |
Beta Was this translation helpful? Give feedback.
-
Describe the bug
Using
@mikro-orm/postgresql
, with a custom type, with an explicit type annotationwill cause the property to always be null, even when it is non-nullable and is set in the database.
However, removing the explicit
: Date
typemakes it work fine.
TimestampType
is based onBigIntType
, but usingBigIntType
instead did not cause the same issue with/without the type annotation.@mikro-orm/better-sqlite
seems to work fine in both scenarios.This started happening sometime between v6.0.2 and v6.0.7, I pinned to v6.0.2 to work around it until now.
Reproduction
https://github.com/sylv/mikro-orm-custom-types-null-issue (I didn't see the repro template, sorry)
pnpm install
DB_URI=postgres://... pnpm watch
The output at first will be
UserEntity { createdAt: null, id: 1 }
, which should not be possible.Opening
user.entity.ts
and changingcreatedAt: Date
tocreatedAt
will outputUserEntity { createdAt: 2024-05-06T08:00:07.812Z, id: 1 }
, which is what is expected.What driver are you using?
@mikro-orm/postgresql
MikroORM version
6.2.5
Node.js version
20.11.1 (ts 5.4.5)
Operating system
Ubuntu 22.04.4
Validations
Beta Was this translation helpful? Give feedback.
All reactions