scarney81 / pg-hstore Goto Github PK
View Code? Open in Web Editor NEWA node package for serializing and deserializing JSON data to hstore format
License: MIT License
A node package for serializing and deserializing JSON data to hstore format
License: MIT License
File LICENSE
mentions Eloqua (instead of the author) as the copyright holder. Is this correct?
I'm using the node "pg" npm module to connect to postgres. Suppose I have a table like this:
create table somedata (col hstore)
if I insert into the table from node like this:
client.query(
"insert into somedata (col) values ($1)",
[hstore.stringify({a:"a'"})]
)
I will get a double sanitization so the key is a
and the value is a''
. I think it would be valuable to have a stringify
that doesn't sanitize so that the resulting strings would be ready for use in prepared statements or statements with place holders where the sanitization is done within the database.
Thanks
I found an error in regexp
var hstore = require('pg-hstore')({ sanitize: true });
var obj = {"description": "", "manufacturer": "Fair-Rite"};
var hstore = hstore.stringify(obj);
var objagain = hstore.parse(hstore); //error
I read the source code about hstore.stringify
: https://github.com/scarney81/pg-hstore/blob/master/lib/index.js#L32
if (!callback || callback === null) return joined;
callback(joined);
It also works fine without passing callback
argument. Like this:
const hstore = require('pg-hstore')();
const dataParsed = hstore.parse(data);
const dataStringified = hstore.stringify(data);
Am I correct?
Hi!
Thanks for the useful module. I found the following issue - and have submitted some code for you to review.
An example of invalid hstores are: "foo"=>"bar,foo,bar" and "foo"=>""bar","foo","bar""
Hope this helps.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.