Converting drizzle custom type to Postgres composite type fails for arrays
I have a postgres composite type in my database consisting of three fields,
Any idea if this is an issue on my side or a drizzle bug?
accountNumber, beneficiaryName, bankId
. I have overridden the toDriver
implementation to try and handle insertion of this custom type as follows:
This works fine and as expected when the column I am inserting into is defined as type payment_config.beneficiary_account
. The problem occurs when the column is defined as an array of that type, i.e. allowedBeneficiaries: beneficiaryAccount('allowed_beneficiaries').array()
which means the column type is payment_config.beneficiary_account[]
.
Now when I try to insert using drizzle and an array of BeneficiaryAccount
, the data does not serialise correctly and the resultant error is malformed record literal: "[object Object]"
. An example query that is produced is
So it looks like the parameter value for allowedBeneficiaries: BeneficiaryAccount[]
is not being converted correctly.
If I change my toDriver
implementation to return a string (e.g. (${accountNumber},${beneficiaryName},${bankId})
, then it works, except in the cases where there are special characters that need to be escaped (e.g. "
).Any idea if this is an issue on my side or a drizzle bug?
2 Replies
Didn't test with postgres composite types it. I need to check
is there any progress on this?