Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Here you go. #6

Merged
2 commits merged into from
Dec 19, 2010
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/.emacs-project
*.swp
2 changes: 1 addition & 1 deletion lib/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ p.submit = function(connection) {
};
};
var handleDatarow = function(msg) {
var result = [];
var result = {};
for(var i = 0; i < msg.fields.length; i++) {
var rawValue = msg.fields[i];
result[names[i]] = rawValue === null ? null : converters[i](rawValue);
Expand Down
13 changes: 12 additions & 1 deletion test/integration/client/simple-query-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,25 @@ test("simple query interface", function() {

var client = helper.client();

var query = client.query("select name from person");
var query = client.query("select name from person order by name");

client.on('drain', client.end.bind(client));

var rows = [];
query.on('row', function(row) {
rows.push(row['name'])
});
query.once('row', function(row) {
test('Can iterate through columns', function () {
var columnCount = 0;
for (column in row) {
columnCount++;
};
if ('length' in row) {
assert.length(row, columnCount, 'Iterating through the columns gives a different length from calling .length.');
}
});
});

assert.emits(query, 'end', function() {
test("returned right number of rows", function() {
Expand Down
11 changes: 11 additions & 0 deletions test/integration/client/test-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ module.exports = {
host: helper.args.host,
port: helper.args.port
});
client.on('error', function(e, d) {
console.log(e);
});
var rawQuery = client.query;
client.query = function() {
var q = rawQuery.apply(this, arguments);
q.on('error', function(e) {
console.log(e);
});
return q;
};
client.connect();
return client;
},
Expand Down
10 changes: 10 additions & 0 deletions test/test-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ buffers = require(__dirname + '/test-buffers');
Connection = require('connection');
var args = require(__dirname + '/cli');

process.on('uncaughtException', function(d) {
if ('stack' in d && 'message' in d) {
console.log("Message: " + d.message);
console.log(d.stack);
} else {
console.log(d);
}
});

assert.same = function(actual, expected) {
for(var key in expected) {
assert.equal(actual[key], expected[key]);
Expand Down Expand Up @@ -102,6 +111,7 @@ assert.isNull = function(item, message) {

test = function(name, action) {
test.testCount ++;
console.log('\n' + name);
var result = action();
if(result === false) {
test.ignored.push(name);
Expand Down