Skip to content

Commit cc86ee6

Browse files
author
Aurynn Shaw
committed
Re-broke prepared queries.
Mostly successfully migrated to the internal Transaction object metaphor. Queries are once again working successfully in the TX format.
1 parent 96ed8d3 commit cc86ee6

File tree

3 files changed

+150
-75
lines changed

3 files changed

+150
-75
lines changed

demo.js

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,29 @@ var pg = require("./lib/postgres-pure");
33
pg.DEBUG=0;
44

55
var db = new pg.connect("pgsql://test:12345@localhost:5432/template1");
6-
db.prepare("SELECT ?::int", function (sth) {
7-
sth.execute([1], function (rs) {
8-
for (var i = 0; i < rs.length; i++) {
9-
for (var key in rs[i]) {
10-
if (rs[i].hasOwnProperty(key)) {
11-
sys.puts(key +": " +rs[i][key]);
12-
}
13-
}
14-
}
15-
db.end();
16-
});
17-
sth.execute([2], function (rs) {
18-
sys.puts(sys.inspect(rs));
19-
})
20-
});
6+
db.query("SELECT 1::int as foobar;", function (rs) {
7+
sys.puts(sys.inspect(rs));
8+
db.close();
9+
});
10+
11+
// db.prepare("SELECT ?::int AS foobar", function (sth) {
12+
// sth.execute([1], function (rs) {
13+
// sys.puts(sys.inspect(rs));
14+
// });
15+
// sth.execute([2], function (rs) {
16+
// sys.puts(sys.inspect(rs));
17+
//
18+
// });
19+
// });
20+
//
21+
// db.transaction(function (tx) {
22+
// tx.query("SELECT ?::int AS foobar", 1, function (rs) {
23+
// sys.puts(sys.inspect(rs));
24+
// });
25+
// tx.prepare("SELECT ?::int AS foobar", function (sth) {
26+
// sth.execute(2, function (rs) {
27+
// sys.puts(sys.inspect(rs));
28+
// });
29+
// });
30+
// tx.commit();
31+
// });

0 commit comments

Comments
 (0)