Comparing version 0.4.4 to 0.5.0
@@ -0,1 +1,6 @@ | ||
0.5.0 / 2013-06-22 | ||
================== | ||
* Update to use node-pg 2.0 | ||
* Properly handle json return type, no more manual parse required | ||
0.4.4 / 2013-06-21 | ||
@@ -2,0 +7,0 @@ ================== |
@@ -20,6 +20,17 @@ var ref$, _mk_func, compileCoffeescript, compileLivescript, xpressionToBody, plv8xSql, operatorsSql, _eval, _apply, _require, _mk_json_eval, _mk_json_eval_ls, _boot; | ||
} | ||
if (pg_version < '9.2.0') { | ||
x$.query('DO $$ BEGIN\n CREATE FUNCTION plv8x.json_syntax_check(src text) RETURNS boolean AS \'\n try { JSON.parse(src); return true; } catch (e) { return false; }\n \' LANGUAGE plv8 IMMUTABLE;\nEXCEPTION WHEN OTHERS THEN END; $$;\n\nDO $$ BEGIN\n CREATE DOMAIN plv8x.json AS text CHECK ( plv8x.json_syntax_check(VALUE) );\nEXCEPTION WHEN OTHERS THEN END; $$;'); | ||
if (pg_version >= '9.1.0' && pg_version < '9.2.0') { | ||
x$.query('DO $$ BEGIN\n CREATE EXTENSION IF NOT EXISTS json WITH SCHEMA pg_catalog;\nEXCEPTION WHEN OTHERS THEN END; $$;'); | ||
} | ||
if (pg_version < '9.1.0') { | ||
throw "json extension required, this is not supported for pg 9.0 yet"; | ||
} else { | ||
x$.query('DO $$ BEGIN\n CREATE DOMAIN plv8x.json AS json;\nEXCEPTION WHEN OTHERS THEN END; $$;'); | ||
x$.query('select oid from pg_catalog.pg_type where typname = \'json\' and typtype =\'b\';', [], function(err, res){ | ||
var that, ref$; | ||
if (that = res != null ? (ref$ = res.rows) != null ? ref$[0] : void 8 : void 8) { | ||
return this$.registerJsonType(that.oid); | ||
} else { | ||
throw "please install json_91 extension from: https://bitbucket.org/adunstan/json_91/src"; | ||
} | ||
}); | ||
} | ||
@@ -26,0 +37,0 @@ y$ = this$.conn; |
@@ -39,3 +39,3 @@ var PLX, slice$ = [].slice, this$ = this, out$ = typeof exports != 'undefined' && exports || this; | ||
var ref$; | ||
return cb(JSON.parse(it != null ? (ref$ = it[0]) != null ? ref$.ret : void 8 : void 8)); | ||
return cb(it != null ? (ref$ = it[0]) != null ? ref$.ret : void 8 : void 8); | ||
}); | ||
@@ -52,3 +52,3 @@ }; | ||
var ref$; | ||
return cb(JSON.parse(it != null ? (ref$ = it[0]) != null ? ref$.ret : void 8 : void 8)); | ||
return cb(it != null ? (ref$ = it[0]) != null ? ref$.ret : void 8 : void 8); | ||
}); | ||
@@ -167,8 +167,13 @@ }; | ||
exports['new'] = function(db, cb){ | ||
var conn, plx; | ||
var pg, x$, conn, plx; | ||
if (db.indexOf('/') < 0) { | ||
db = "tcp://localhost/" + db; | ||
} | ||
conn = connect(db); | ||
pg = require('pg'); | ||
x$ = conn = new pg.Client(db); | ||
x$.connect(); | ||
plx = new PLX(conn); | ||
plx.registerJsonType = function(oid){ | ||
return pg.types.setTypeParser(oid, 'text', JSON.parse.bind(JSON)); | ||
}; | ||
return plx.bootstrap(function(){ | ||
@@ -175,0 +180,0 @@ return plx.query('select plv8x.boot()', function(){ |
@@ -10,3 +10,3 @@ { | ||
"description": "Use JavaScript expressions and modules in PostgreSQL plv8", | ||
"version": "0.4.4", | ||
"version": "0.5.0", | ||
"keywords": [ | ||
@@ -35,3 +35,3 @@ "postgres", | ||
"optimist": "0.3.x", | ||
"pg": "1.0.x", | ||
"pg": "2.0.x", | ||
"resolve": "0.3.x", | ||
@@ -38,0 +38,0 @@ "one": "2.5.x", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
77180
1167
+ Addedbindings@1.5.0(transitive)
+ Addedfile-uri-to-path@1.0.0(transitive)
+ Addedgeneric-pool@2.0.3(transitive)
+ Addedpg@2.0.0(transitive)
+ Addedref@0.1.3(transitive)
- Removedgeneric-pool@2.0.2(transitive)
- Removedpg@1.0.4(transitive)
Updatedpg@2.0.x