Closed andreo-k closed 4 years ago
Is the issue that the transformer doesn't work if NULL values are provided?
well, yes and no. I use typeorm-encrypted with typeorm and mysql. And when there is null in column, typeorm sends '' (empty string) to the 'to' method. Then encryptor fails.
Hmmm so I just tested null
and undefined
values out for the transformer. It works as it should. Basically, any null
or undefined
value in the entity shouldn't be transformed. Empty strings should be transformed/encrypted.
Just to be sure, are you passing null
or undefined
as the value for that column in the entity? Also, If the to
method is receiving an empty string, then you're likely providing an empty string to the entity instead of null
or undefined
.
Otherwise, this could be an issue specifically with the MySQL handler in Typeorm
rather than typeorm-encrypted
.
I'll follow up with them as well... stay tuned :).
are you passing null or undefined
well, I am passing null, then save the entity with typeorm, then see the entity record in my sql with the NULL, then read the entity with typeorm and typeorm-encrypted gets '' into the to method. Yes probably it is typeorm + mysql issue, that it passes '' when there is actually NULL, but in any case typeorm-encrypted does not work on ''.
Oh, if it's on the read side, then that should be fine.
@andreo-k I added a couple of notes. Basically, on the save side, no changes are needed. On the read side, your change works.
@generalpiston I removed changes from 'save' side, pushed to same branch
Merged. Thanks @andreo-k . I'll create a new release too.
Version 0.5.6 has this patch @andreo-k .
fixed the issue. pls merge in my pull-request