Fixes #1358#1364
Fixes #1358#1364janmeier merged 9 commits intosequelize:masterfrom SohumB:bugfix/use-ishash-to-avoid-buffers
Conversation
|
Could you provide a test aswell? So we don't have regression bugs later :) |
|
Thanks for the push to do so - and I found another bug while writing the test :p I'll add a test for the associations pathway I found the bug by in a sec. |
There was a problem hiding this comment.
Could you please check that the user matching the buffer is actually returned, and that the data is a buffer?
users[0].binary instanceof Buffer
There was a problem hiding this comment.
AFAIK, the database itself returns the data as a string here. Sequelize would have to check input to binary fields (in .build?) and specifically convert them into a buffer, I think.
There was a problem hiding this comment.
We return data in BLOBs as buffers (https://github.com/sequelize/sequelize/blob/master/test/dao-factory.test.js#L1826), so I just though it might make sense to do the same for BINARY fields. I actually though it was already impemented though :)
The conversion happen in query.js as i recall it
There was a problem hiding this comment.
Judging from a grep of the source code, Sequelize only does a conversion into Buffer for mariadb and sqlite.
There was a problem hiding this comment.
Jup, mysql and postgres handles the conversion automagically :)
|
Why is Travis is failing on postgres here? All that it's getting to is declaring the field as a |
lib/dao-factory.js
Outdated
There was a problem hiding this comment.
return elem should be enough
|
Postgres must not support STRING BINARY, any experience with this @janmeier ? |
|
Nope, seems to only support Must have been missing tests for that :D |
|
Guess so. I guess we'll have to wrap the tests for this in != postgres. |
|
If we do so we should also throw an error, if the user tries to create a binary string column under postgres. Or perhaps just use a bytea column?
http://stackoverflow.com/questions/8476968/varbinary-vs-blob-in-mysql The distinction seem to be neglible |
|
Hmm good question. Overall we need to decide if we want to make compatability code for stuff like this or just let the user pick the right types and throw errors if not supported. Ideally an ORM should work regardless of the database behind (ofcourse thats utopian but a nice idea) |
|
A bytea column seems to me to be the best option. The docs do say it's postgres' version of binary strings. (For my usecase, I'd just use the UUID type :P) |
|
@SohumB Want to take a crack at bytea? |
|
Done! I think. Found another bug, too - you're depending on But yea, done! Probably! |
|
Wait, hang on. Why are the |
|
@SohumB it is? Some test was failing originally atleast. |
|
Looks like solid work. @janmeier mind taking a look too? |
|
It is now, I mean. The original error was that postgres didn't understand BINARY, then that |
|
Jup, looks solid to me as well |
|
Tests are green! Let's assume it works! :D |
Buffer essentially needs handling like a base type, as far as I can tell. That, and isHash should really encapsulate the logic of finding actual hashes rather than JS objects.