rethinkdbdash
Advanced tools
Comparing version 2.1.17 to 2.2.0
@@ -469,2 +469,9 @@ var net = require('net'); | ||
} | ||
else if (type === responseTypes.SERVER_INFO) { | ||
self.emit('release'); | ||
datum = helper.makeAtom(response, self.metadata[token].options); | ||
self.metadata[token].resolve(datum); | ||
delete self.metadata[token]; | ||
} | ||
} | ||
@@ -571,2 +578,15 @@ | ||
Connection.prototype.server = function(callback) { | ||
var self = this; | ||
return new Promise(function(resolve, reject) { | ||
var query = [protodef.Query.QueryType.SERVER_INFO]; | ||
self._send(query, self._getToken(), resolve, reject, undefined, undefined, true); | ||
}).nodeify(callback); | ||
} | ||
// Return the next token and update it. | ||
Connection.prototype._getToken = function() { | ||
return this.token++; | ||
} | ||
Connection.prototype.close = function(options, callback) { | ||
@@ -605,3 +625,3 @@ if (typeof options === 'function') { | ||
var self = this; | ||
var token = self.token++; | ||
var token = self._getToken(); | ||
@@ -608,0 +628,0 @@ var p = new Promise(function(resolve, reject) { |
@@ -54,6 +54,6 @@ var Promise = require('bluebird'); | ||
if (self._closed === true) { | ||
reject(new Err.ReqlDriverError('You cannot called `next` on a closed '+this._type)) | ||
reject(new Err.ReqlDriverError('You cannot call `next` on a closed '+this._type)) | ||
} | ||
else if ((self._data.length === 0) && (self._canFetch === false)) { | ||
reject(new Err.ReqlDriverError('No more rows in the '+self._type).setOperational()) | ||
reject(new Err.ReqlDriverError('No more rows in the '+self._type.toLowerCase()).setOperational()) | ||
} | ||
@@ -167,3 +167,3 @@ else { | ||
else { | ||
reject(new Err.ReqlDriverError('No more rows in the '+this._type).setOperational()) | ||
reject(new Err.ReqlDriverError('No more rows in the '+this._type.toLowerCase()).setOperational()) | ||
} | ||
@@ -212,3 +212,3 @@ } | ||
var reject = function(err) { | ||
if (err.message === 'No more rows in the '+self._type+'.') { | ||
if (err.message === 'No more rows in the '+self._type.toLowerCase()+'.') { | ||
if (typeof onFinish === 'function') { | ||
@@ -233,3 +233,3 @@ onFinish(); | ||
if ((error.message !== 'You cannot retrieve data from a cursor that is closed.') && | ||
(error.message.match(/You cannot called `next` on a closed/) === null)) { | ||
(error.message.match(/You cannot call `next` on a closed/) === null)) { | ||
reject(error); | ||
@@ -246,3 +246,3 @@ } | ||
if ((error.message !== 'You cannot retrieve data from a cursor that is closed.') && | ||
(error.message.match(/You cannot called `next` on a closed/) === null)) { | ||
(error.message.match(/You cannot call `next` on a closed/) === null)) { | ||
reject(error); | ||
@@ -254,9 +254,9 @@ } | ||
this.next = function() { | ||
throw new Err.ReqlDriverError('You cannot called `next` once you have bound listeners on the '+this._type) | ||
throw new Err.ReqlDriverError('You cannot call `next` once you have bound listeners on the '+this._type) | ||
} | ||
this.each = function() { | ||
throw new Err.ReqlDriverError('You cannot called `each` once you have bound listeners on the '+this._type) | ||
throw new Err.ReqlDriverError('You cannot call `each` once you have bound listeners on the '+this._type) | ||
} | ||
this.toArray = function() { | ||
throw new Err.ReqlDriverError('You cannot called `toArray` once you have bound listeners on the '+this._type) | ||
throw new Err.ReqlDriverError('You cannot call `toArray` once you have bound listeners on the '+this._type) | ||
} | ||
@@ -263,0 +263,0 @@ this._eventEmitter = new EventEmitter(); |
@@ -110,6 +110,6 @@ var helper = require(__dirname+'/helper.js'); | ||
break; | ||
case protoErrorType.RESOURCE: | ||
case protoErrorType.RESOURCE_LIMIT: | ||
this.name = 'ReqlResourceError'; | ||
break; | ||
case protoErrorType.LOGIC: | ||
case protoErrorType.QUERY_LOGIC: | ||
this.name = 'ReqlLogicError'; | ||
@@ -326,2 +326,3 @@ break; | ||
KEYS: 'keys', | ||
VALUES: 'values', | ||
MATCH: 'match', | ||
@@ -328,0 +329,0 @@ UPCASE: 'upcase', |
@@ -421,7 +421,6 @@ var Promise = require('bluebird'); | ||
r.prototype.uuid = function() { | ||
if (Term.prototype._fastArity(arguments.length, 0) === false) { | ||
var _len = arguments.length;var _args = new Array(_len); for(var _i = 0; _i < _len; _i++) {_args[_i] = arguments[_i];} | ||
Term.prototype._arity(_args, 0, 'uuid', this); | ||
} | ||
return new Term(this).uuid(); | ||
var _len = arguments.length;var _args = new Array(_len); for(var _i = 0; _i < _len; _i++) {_args[_i] = arguments[_i];} | ||
Term.prototype._arityRange(_args, 0, 1, 'r.uuid', this); | ||
var term = new Term(this); | ||
return term.uuid(_args[0]); | ||
} | ||
@@ -428,0 +427,0 @@ |
@@ -24,3 +24,4 @@ // DO NOT EDIT | ||
STOP: 3, | ||
NOREPLY_WAIT: 4 | ||
NOREPLY_WAIT: 4, | ||
SERVER_INFO: 5 | ||
}, | ||
@@ -46,2 +47,3 @@ | ||
WAIT_COMPLETE: 4, | ||
SERVER_INFO: 5, | ||
CLIENT_ERROR: 16, | ||
@@ -54,4 +56,4 @@ COMPILE_ERROR: 17, | ||
INTERNAL: 1000000, | ||
RESOURCE: 2000000, | ||
LOGIC: 3000000, | ||
RESOURCE_LIMIT: 2000000, | ||
QUERY_LOGIC: 3000000, | ||
NON_EXISTENCE: 3100000, | ||
@@ -130,2 +132,3 @@ OP_FAILED: 4100000, | ||
KEYS: 94, | ||
VALUES: 186, | ||
OBJECT: 143, | ||
@@ -132,0 +135,0 @@ HAS_FIELDS: 32, |
{ | ||
"name": "rethinkdbdash", | ||
"version": "2.1.17", | ||
"version": "2.2.0", | ||
"description": "A Node.js driver for RethinkDB with promises and a connection pool", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -12,2 +12,3 @@ var config = require(__dirname+'/config.js'); | ||
It('Testing `run` without connection', function* (done) { | ||
@@ -358,6 +359,15 @@ try { | ||
It('`server` should work', function* (done) { | ||
try{ | ||
connection = yield r.connect(config); | ||
var response = yield connection.server(); | ||
assert(typeof response.name === 'string'); | ||
assert(typeof response.id === 'string'); | ||
done(); | ||
} | ||
catch(e) { | ||
done(e); | ||
} | ||
}) | ||
/* Since 1.13, the token is stored oustide the query, so this error shouldn't happen anymore | ||
@@ -364,0 +374,0 @@ It('`connection` should extend events.Emitter and emit an error if the server failed to parse the protobuf message', function* (done) { |
@@ -466,1 +466,12 @@ var config = require(__dirname+'/config.js'); | ||
}) | ||
It('`r.uuid("foo")` should work', function* (done) { | ||
try { | ||
var result = yield r.uuid("rethinkdbdash").run(); | ||
assert.equal(result, '291a8039-bc4b-5472-9b2a-f133254e3283'); | ||
done(); | ||
} | ||
catch(e) { | ||
done(e) | ||
} | ||
}) |
@@ -208,3 +208,3 @@ var config = require('./config.js'); | ||
catch(e) { | ||
if (e.message === "No more rows in the Cursor.") { | ||
if (e.message === "No more rows in the cursor.") { | ||
assert.equal(smallNumDocs, i); | ||
@@ -323,3 +323,3 @@ done(); | ||
catch(e) { | ||
if ((i > 0) && (e.message === "No more rows in the Cursor.")) { | ||
if ((i > 0) && (e.message === "No more rows in the cursor.")) { | ||
connection.close(); | ||
@@ -449,3 +449,3 @@ done() | ||
var idValue = uuid(); | ||
feed = yield r.db(dbName).table(tableName2).get(idValue).changes().run(); | ||
feed = yield r.db(dbName).table(tableName2).get(idValue).changes({includeInitial: true}).run(); | ||
setTimeout(function() { | ||
@@ -558,3 +558,3 @@ r.db(dbName).table(tableName2).insert({id: idValue}).run(); | ||
}, function(e) { | ||
if (e.message === 'You cannot called `next` once you have bound listeners on the Feed.') { | ||
if (e.message === 'You cannot call `next` once you have bound listeners on the Feed.') { | ||
feed.close().then(function() { | ||
@@ -686,3 +686,3 @@ done(); | ||
try { | ||
feed = yield r.db(dbName).table(tableName).orderBy({index: 'id'}).limit(10).changes({includeStates: true}).run(); | ||
feed = yield r.db(dbName).table(tableName).orderBy({index: 'id'}).limit(10).changes({includeStates: true, includeInitial: true}).run(); | ||
var i = 0; | ||
@@ -689,0 +689,0 @@ feed.each(function(err, change) { |
@@ -252,65 +252,1 @@ var config = require(__dirname+'/config.js'); | ||
/* | ||
// RethinkDB seems to properly handle the null character now | ||
It("Null char in string - 1", function* (done) { | ||
try{ | ||
result = yield r.expr("T\u0000EST").run(); | ||
assert.equal(result, "T\u0000EST"); | ||
done(new Error('Was expecting an error')); | ||
} | ||
catch(e) { | ||
if (e.message.match(/^The null character is currently not supported by RethinkDB/)) { | ||
done(); | ||
} | ||
else { | ||
console.log(e.message); | ||
done(e); | ||
} | ||
} | ||
}) | ||
It("Null char in string - 2", function* (done) { | ||
try{ | ||
result = yield r.expr(1).do(function(key) { | ||
return r.json(JSON.stringify('"T\u0000EST"')) | ||
}).run(); | ||
assert.equal(result, JSON.stringify("T\u0000EST")); | ||
done(new Error('Was expecting an error')); | ||
} | ||
catch(e) { | ||
if (e.message.match(/^The null character is currently not supported by RethinkDB/)) { | ||
done(); | ||
} | ||
else { | ||
console.log(e.message); | ||
done(e); | ||
} | ||
} | ||
}) | ||
It("Null char in string - 3", function* (done) { | ||
try{ | ||
result = yield r.json("T\u0000EST").run(); | ||
assert.equal(result, "T\u0000EST"); | ||
done(new Error('Was expecting an error')); | ||
} | ||
catch(e) { | ||
if (e.message.match(/^The null character is currently not supported by RethinkDB/)) { | ||
done(); | ||
} | ||
else { | ||
console.log(e.message); | ||
done(e); | ||
} | ||
} | ||
}) | ||
It("Null char in string should not throw if not run", function* (done) { | ||
try{ | ||
r.expr("\00") | ||
done(); | ||
} | ||
catch(e) { | ||
done(e); | ||
} | ||
}); | ||
*/ |
@@ -620,2 +620,14 @@ var config = require(__dirname+'/config.js'); | ||
}) | ||
It('`values` should work', function* (done) { | ||
try { | ||
var result = yield r.expr({a:0, b:1, c:2}).values().orderBy(r.row).run(); | ||
assert.deepEqual(result, [0, 1, 2]); | ||
done() | ||
} | ||
catch(e) { | ||
done(e); | ||
} | ||
}) | ||
It('`object` should work', function* (done) { | ||
@@ -622,0 +634,0 @@ try { |
@@ -15,3 +15,3 @@ var Promise = require('bluebird'); | ||
//query = 'r.table("foo").add(1).add(1).add("hello-super-long-string").add("another-long-string").add("one-last-string").map( function(doc) { return r.expr([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]).map(function(test) { return test("b").add("hello-super-long-string").add("another-long-string").add("one-last-string").add("hello-super-long-string").add("another-long-string").add("one-last-string").add("hello-super-long-string").add("another-long-string").add("one-last-string").add("hello-super-long-string").add("another-long-string").add("one-last-string").add("hello-super-long-string").add("another-long-string").add("one-last-string").mul(test("b")).merge({ firstName: "xxxxxx", lastName: "yyyy", email: "xxxxx@yyyy.com", phone: "xxx-xxx-xxxx" }); }).add(2).map(function(doc) { return doc.add("hello-super-long-string").add("another-long-string").add("one-last-string").add("hello-super-long-string").add("another-long-string").add("one-last-string").add("hello-super-long-string").add("another-long-string").add("one-last-string").add("hello-super-long-string").add("another-long-string").add("one-last-string").add("hello-super-long-string").add("another-long-string").add("one-last-string") }); })'; | ||
query = 'r.db(dbName).table(tableName).map(function(doc) { return doc("key").add(undefined)})'; | ||
query = 'r.expr({a:1, b:2, c: 3}).values().add(2)'; | ||
Promise.coroutine(function* () { | ||
@@ -18,0 +18,0 @@ try { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
24922
816686