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

Commit 370e808a by Mick Hansen

Merge pull request #1611 from seegno/fix-hstore-number-cast

Fix hstore parse number conversion
2 parents 7c90ba6e 48e04c4d
var _ = require('lodash')
module.exports = {
stringifyPart: function(part) {
switch(typeof part) {
......@@ -30,7 +32,7 @@ module.exports = {
case '[':
return JSON.parse(part)
default:
return part
return _.isFinite(part) ? parseFloat(part) : part
}
},
parse: function(string) {
......
......@@ -116,7 +116,7 @@ if (dialect.match(/^postgres/)) {
})
it('should handle multiple keys with different types of values', function(done) {
expect(hstore.parse('"true"=>true,"false"=>false,"null"=>NULL,"undefined"=>NULL,"integer"=>1,"array"=>"[1,\\"2\\"]","object"=>"{\\"object\\":\\"value\\"}"')).to.deep.equal({ true: true, false: false, null: null, undefined: null, integer: "1", array: [1,'2'], object: { object: 'value' }})
expect(hstore.parse('"true"=>true,"false"=>false,"null"=>NULL,"undefined"=>NULL,"integer"=>1,"array"=>"[1,\\"2\\"]","object"=>"{\\"object\\":\\"value\\"}"')).to.deep.equal({ true: true, false: false, null: null, undefined: null, integer: 1, array: [1,'2'], object: { object: 'value' }})
done()
})
})
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!