New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fail to insert entity with Buffer type of primary column under some circumstances. #4060
Comments
A recent fix with Typeorm resolved an issue with updating an entry with a Buffer which is not the primary key. However, this is still an issue v0.2.28. This is the payload I send into my entity create function: {
id: <Buffer 11 eb 0c 81 c9 f3 1e 40 87 3a 63 96 87 e2 ca 27>,
anotherBufferColumn: <Buffer 11 e8 46 cb b2 9d 9d d4 b7 9a 02 42 ac 11 00 04>,
text: "Hello world"
} This is what is created: {
id: <Buffer 11 eb 0c 81 c9 f3 1e 40 87 3a 63 96 87 e2 ca 27>,
text: "Hello world"
} @angushe |
@MechJosh0 what recent fix are you referring to ? |
@elovin I actually realised the error was my side. I've created a small working demo repo for you which will:
https://github.com/MechJosh0/typeorm-buffer-example Hopefully, this helps you to see what I've done to have it working. |
I extended the example provided by @MechJosh0 for 16bit hex encoded uuids and this works just fine with mysql/mariadb. |
* fixed using Buffer in relations * removed console.log * added test for #4060
Issue type:
[x] question
[ ] bug report
[ ] feature request
[ ] documentation issue
Database system/driver:
[ ]
cordova
[ ]
mongodb
[ ]
mssql
[x]
mysql
/mariadb
[ ]
oracle
[ ]
postgres
[ ]
cockroachdb
[ ]
sqlite
[ ]
sqljs
[ ]
react-native
[ ]
expo
TypeORM version:
[x]
latest
[ ]
@next
[ ]
0.x.x
(or put your version here)Steps to reproduce or a small repository showing the problem:
There are two entities which are called Foo and Bar respectively. Foo and Bar have a 1-1 relationship defined on primary columns <Foo.id>/<Bar.id>.
After running the following test code:
I got the error:
If I change the data types of Foo.id and Bar.id from Buffer to string or other primitive types), it works.
After some investigations into typeorm source codes, I made a quick dirty change(Buffer type check added) to
typeorm/src/metadata/ColumnMetadata.ts
Line 588 in f380452
it works again.
Any thoughts?
The text was updated successfully, but these errors were encountered: