Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
9a68682
First tests passing for new native bindings
brianc Sep 13, 2014
b325971
Make more tests pass
brianc Sep 14, 2014
667c528
Work towards more tests passing
brianc Sep 14, 2014
d2bb532
Make moar tests pass
brianc Sep 15, 2014
e99f8d5
Remove test skip
brianc Sep 15, 2014
c5d4207
Fix a few more failing tests
brianc Sep 23, 2014
7547322
Print out unfired function
brianc Oct 1, 2014
69243ea
Bump version of pg-native
brianc Oct 5, 2014
dd2e71c
Fix max connection tests
brianc Oct 7, 2014
3867851
Make cancel query tests pass
brianc Oct 10, 2014
613112c
Upgrade to pg-native 1.2.0 to support rowMode:array
brianc Oct 10, 2014
4c5f3ab
Add support for native rowMode: array
brianc Oct 11, 2014
2de9838
Merge remote-tracking branch 'origin/master' into libpq
brianc Oct 11, 2014
0b2344b
Remove COPY TO / COPY FROM
brianc Oct 11, 2014
24ef17a
Merge with origin/master
brianc Oct 16, 2014
73814d9
Pin pg-native version
brianc Oct 17, 2014
e7e5f1c
Update pg-native version
brianc Oct 18, 2014
89d0938
Subscribe to notification before emitting connected
brianc Oct 18, 2014
c3513a2
Make native bindings an optional install
brianc Oct 18, 2014
5dff313
Remove dead file
brianc Oct 18, 2014
21f6dbe
Break native result into its own file
brianc Oct 18, 2014
6876fa1
Add semver as hard dependency
brianc Oct 18, 2014
44f8149
Publish beta version
brianc Oct 19, 2014
d4b88fe
bump version
brianc Oct 20, 2014
35596fd
Upgrade version of pg-native
brianc Nov 18, 2014
06b0392
Update travis config
brianc Nov 18, 2014
a8a3f3c
Update version of pg-native
brianc Nov 18, 2014
fb2db08
Merge with origin/master
brianc Nov 18, 2014
40c50e7
Update .travis.yml
brianc Nov 18, 2014
f4f5e54
Install proper version of pg-native
brianc Nov 18, 2014
aa901a2
Fix travis tests
brianc Nov 18, 2014
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 .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
language: node_js
node_js:
- "0.10"
- "0.11"
before_script:
- node script/create-test-tables.js pg://postgres@127.0.0.1:5432/postgres
env:
Expand Down
36 changes: 17 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,26 @@ params := $(connectionString)
node-command := xargs -n 1 -I file node file $(params)

.PHONY : test test-connection test-integration bench test-native \
build/default/binding.node jshint upgrade-pg publish
jshint publish test-missing-native update-npm

all:
npm install

build:
node-gyp rebuild

help:
@echo "make prepare-test-db [connectionString=postgres://<your connection string>]"
@echo "make test-all [connectionString=postgres://<your connection string>]"

test: test-unit

test-all: jshint test-unit test-integration test-native test-binary
test-all: jshint test-missing-native test-unit test-integration test-native test-binary

test-travis: test-all upgrade-pg
#@make test-all connectionString=postgres://postgres@localhost:5433/postgres

upgrade-pg:
#@chmod 755 script/travis-pg-9.2-install.sh
#@./script/travis-pg-9.2-install.sh
udpate-npm:
@npm i npm --global

bench:
@find benchmark -name "*-bench.js" | $(node-command)

build/default/binding.node:
@node-gyp rebuild

test-unit:
@find test/unit -name "*-tests.js" | $(node-command)

Expand All @@ -47,12 +38,23 @@ test-connection-binary:
@echo "***Testing binary connection***"
@node script/test-connection.js $(params) binary

test-native: build/default/binding.node
test-missing-native:
@echo "***Testing optional native install***"
@rm -rf node_modules/pg-native
@node test/native/missing-native.js
@npm install pg-native@1.4.0
@node test/native/missing-native.js
@rm -rf node_modules/pg-native

node_modules/pg-native/index.js:
@npm i pg-native

test-native: node_modules/pg-native/index.js
@echo "***Testing native bindings***"
@find test/native -name "*-tests.js" | $(node-command)
@find test/integration -name "*-tests.js" | $(node-command) native

test-integration: test-connection build/default/binding.node
test-integration: test-connection
@echo "***Testing Pure Javascript***"
@find test/integration -name "*-tests.js" | $(node-command)

Expand All @@ -67,7 +69,3 @@ prepare-test-db:
jshint:
@echo "***Starting jshint***"
@./node_modules/.bin/jshint lib

publish:
@rm -r build || (exit 0)
@npm publish
38 changes: 0 additions & 38 deletions binding.gyp

This file was deleted.

44 changes: 6 additions & 38 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ var ConnectionParameters = require(__dirname + '/connection-parameters');
var Query = require(__dirname + '/query');
var defaults = require(__dirname + '/defaults');
var Connection = require(__dirname + '/connection');
var CopyFromStream = require(__dirname + '/copystream').CopyFromStream;
var CopyToStream = require(__dirname + '/copystream').CopyToStream;

var Client = function(config) {
EventEmitter.call(this);
Expand Down Expand Up @@ -130,17 +128,6 @@ Client.prototype.connect = function(callback) {
self.activeQuery.handleCopyInResponse(self.connection);
});

con.on('copyOutResponse', function(msg) {
if(self.activeQuery.stream === undefined) {
self.activeQuery._canceledDueToError = new Error('No destination stream defined');
//canceling query requires creation of new connection
//look for postgres frontend/backend protocol
//TODO - this needs to die/be refactored
(new self.constructor({port: self.port, host: self.host}))
.cancel(self, self.activeQuery);
}
});

con.on('copyData', function (msg) {
self.activeQuery.handleCopyData(msg, self.connection);
});
Expand Down Expand Up @@ -185,13 +172,13 @@ Client.prototype.connect = function(callback) {
con.once('end', function() {
if ( callback ) {
// haven't received a connection message yet !
var err = new Error('Connection was ended during query');
var err = new Error('Connection terminated');
callback(err);
callback = null;
return;
}
if(self.activeQuery) {
var disconnectError = new Error('Connection was ended during query');
var disconnectError = new Error('Connection terminated');
self.activeQuery.handleError(disconnectError, con);
self.activeQuery = null;
}
Expand All @@ -209,9 +196,8 @@ Client.prototype.getStartupConf = function() {
var params = this.connectionParameters;

var data = {
user : params.user ,
database : params.database
// client_encoding : "'".concat(params.client_encoding).concat("'")
user: params.user,
database: params.database
};

var appName = params.application_name || params.fallback_application_name;
Expand Down Expand Up @@ -301,30 +287,12 @@ Client.prototype._pulseQueryQueue = function() {
}
};

Client.prototype._copy = function (text, stream) {
var config = {};
config.text = text;
config.stream = stream;
config.callback = function (error) {
if(error) {
config.stream.error(error);
} else {
config.stream.close();
}
};
var query = new Query(config);
this.queryQueue.push(query);
this._pulseQueryQueue();
return config.stream;

};

Client.prototype.copyFrom = function (text) {
return this._copy(text, new CopyFromStream());
throw new Error("For PostgreSQL COPY TO/COPY FROM support npm install pg-copy-streams");
};

Client.prototype.copyTo = function (text) {
return this._copy(text, new CopyToStream());
throw new Error("For PostgreSQL COPY TO/COPY FROM support npm install pg-copy-streams");
};

Client.prototype.query = function(config, values, callback) {
Expand Down
Loading