Fixed empty blob #9441
Fixed empty blob #9441
Conversation
@@ -43,13 +43,7 @@ module.exports = BaseTypes => { | |||
inherits(BLOB, BaseTypes.BLOB); | |||
|
|||
BLOB.parse = function(value, options, next) { | |||
const data = next(); |
sushantdhiman
May 18, 2018
•
Contributor
I dont think this works, can you show me a failing case
I dont think this works, can you show me a failing case
YaroslavRepeta
May 18, 2018
•
Author
Contributor
I'm not sure where the right place to add test case for this.
What I did here is only removed if
what causes returning null instead of empty buffer.
I'm not sure where the right place to add test case for this.
What I did here is only removed if
what causes returning null instead of empty buffer.
sushantdhiman
May 18, 2018
Contributor
Ok show me example of what you are trying to solve, paste it here
Ok show me example of what you are trying to solve, paste it here
YaroslavRepeta
May 18, 2018
•
Author
Contributor
Something like:
expect(
(await model.findOne({ some_where_clause })).empty_buffer_column
).to.equal(Buffer.from(""));
In fact mysql2
what is used returns empty buffer in select queries, when sequelize
catches that and returns null instead.
Something like:
expect(
(await model.findOne({ some_where_clause })).empty_buffer_column
).to.equal(Buffer.from(""));
In fact mysql2
what is used returns empty buffer in select queries, when sequelize
catches that and returns null instead.
Ok so I have tested this change User
.sync({ force: true })
.then(() => {
return User.bulkCreate([{
username: 'anc',
data: Buffer.from('')
}, {
username: 'anc',
data: null
}]);
})
.then(() => {
return User.findAll();
})
.then(users => {
console.log(users[0].data, users[1].data);
});
### Output
<Buffer > null It seems MySQL2 now handles null case correctly, so as expected binary
sequelize/test/integration/model.test.js Line 2562 in 5f7d69a Some related issues #8661 sidorares/node-mysql2#668 |
@@ -43,13 +43,7 @@ module.exports = BaseTypes => { | |||
inherits(BLOB, BaseTypes.BLOB); | |||
|
|||
BLOB.parse = function(value, options, next) { |
sushantdhiman
May 19, 2018
•
Contributor
Remove BLOB function from this file, we will now go with mysql2 default
Remove BLOB function from this file, we will now go with mysql2 default
Pull Request check-list
Please make sure to review and check all of these items:
npm run test
ornpm run test-DIALECT
pass with this change (including linting)?Description of change
SELECT query returns null instead of empty Buffer for BLOB type