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

Commit 48e04c4d by Tiago Ribeiro

Fix hstore parse number conversion

1 parent 7c90ba6e
var _ = require('lodash')
module.exports = { module.exports = {
stringifyPart: function(part) { stringifyPart: function(part) {
switch(typeof part) { switch(typeof part) {
...@@ -30,7 +32,7 @@ module.exports = { ...@@ -30,7 +32,7 @@ module.exports = {
case '[': case '[':
return JSON.parse(part) return JSON.parse(part)
default: default:
return part return _.isFinite(part) ? parseFloat(part) : part
} }
}, },
parse: function(string) { parse: function(string) {
......
...@@ -116,7 +116,7 @@ if (dialect.match(/^postgres/)) { ...@@ -116,7 +116,7 @@ if (dialect.match(/^postgres/)) {
}) })
it('should handle multiple keys with different types of values', function(done) { 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() done()
}) })
}) })
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!