不要怂,就是干,撸起袖子干!

Commit c3b14ed9 by Tiago Ribeiro

Fix hstore bug when parsing null values (#1504)

1 parent 70a0cb3e
...@@ -43,6 +43,8 @@ module.exports = { ...@@ -43,6 +43,8 @@ module.exports = {
const rx = /\"((?:\\\"|[^"])*)\"\s*\=\>\s*((?:true|false|NULL|\d+|\d+\.\d+|\"((?:\\\"|[^"])*)\"))/g const rx = /\"((?:\\\"|[^"])*)\"\s*\=\>\s*((?:true|false|NULL|\d+|\d+\.\d+|\"((?:\\\"|[^"])*)\"))/g
string = string || '';
string.replace(rx, function(match, key, value, innerValue) { string.replace(rx, function(match, key, value, innerValue) {
switch(value) { switch(value) {
case 'true': case 'true':
......
...@@ -90,6 +90,11 @@ if (dialect.match(/^postgres/)) { ...@@ -90,6 +90,11 @@ if (dialect.match(/^postgres/)) {
}) })
describe('parse', function() { describe('parse', function() {
it('should handle null objects correctly', function(done) {
expect(hstore.parse(null)).to.deep.equal({ })
done()
})
it('should handle empty objects correctly', function(done) { it('should handle empty objects correctly', function(done) {
expect(hstore.parse('')).to.deep.equal({ }) expect(hstore.parse('')).to.deep.equal({ })
done() done()
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!