Merge branch 'master' into gh-pages

* master:
  0.1.7
  ensure errors are thrown for  fn's, fixes #16
This commit is contained in:
Tim Griesser 2013-06-12 08:45:05 -04:00
commit d23f5c48e6
5 changed files with 50 additions and 10 deletions

View File

@ -27,7 +27,7 @@
<div class="pilwrap ">
<a class="pilcrow" href="#section-1">&#182;</a>
</div>
<pre><code>Knex.js 0.1.6
<pre><code>Knex.js 0.1.7
(c) 2013 Tim Griesser
Knex may be freely distributed under the MIT license.
@ -91,7 +91,11 @@ http://knexjs.org</code></pre>
</div>
<div class="content"><div class='highlight'><pre> Knex.VERSION = <span class="string">'0.1.6'</span>;</pre></div></div>
<div class="content"><div class='highlight'><pre> Knex.VERSION = <span class="string">'0.1.7'</span>;
<span class="keyword">var</span> rethrower = <span class="keyword">function</span>(err) {
<span class="keyword">throw</span> err;
};</pre></div></div>
</li>
@ -129,7 +133,8 @@ used to generate the sql in one form or another.</p>
</div>
<p>For those who dislike promise interfaces.
Multiple calls to <code>exec</code> will resolve with the same value
if called more than once.</p>
if called more than once. Any unhandled errors will be thrown
after the last block.</p>
</div>
@ -139,6 +144,8 @@ if called more than once.</p>
callback(<span class="literal">null</span>, resp);
}, <span class="keyword">function</span>(err) {
callback(err, <span class="literal">null</span>);
}).then(<span class="literal">null</span>, <span class="keyword">function</span>(err) {
setTimeout(<span class="keyword">function</span>() { <span class="keyword">throw</span> err; }, <span class="number">0</span>);
});
},</pre></div></div>

View File

@ -181,7 +181,7 @@
<div id="sidebar" class="interface">
<a class="toc_title" href="#">
Knex.js <span class="version">(0.1.6)</span>
Knex.js <span class="version">(0.1.7)</span>
</a>
<ul class="toc_section">
<li>&raquo; <a href="https://github.com/tgriesser/knex">GitHub Repository</a></li>
@ -319,7 +319,7 @@
or send tweets to <a href="http://twitter.com/tgriesser">@tgriesser</a>.
</p>
<h2>Latest Release: 0.1.6</h2>
<h2>Latest Release: 0.1.7</h2>
<p>
Current Develop &mdash;
@ -1135,6 +1135,11 @@ Knex.Raw('select * from users where id = 1').then(function(resp) {
<h2 id="changelog">Change Log</h2>
<p>
<b class="header">0.1.7</b> &mdash; <small><i>June 12, 2013</i></small><br />
Ensures unhandled errors in the <tt>exec</tt> callback interface are re-thrown.
</p>
<p>
<b class="header">0.1.6</b> &mdash; <small><i>June 9, 2013</i></small><br />
Renaming <tt>beforeCreate</tt> to <tt>afterCreate</tt>. Better handling of errors in the connection pooling.

13
knex.js
View File

@ -1,4 +1,4 @@
// Knex.js 0.1.6
// Knex.js 0.1.7
//
// (c) 2013 Tim Griesser
// Knex may be freely distributed under the MIT license.
@ -23,7 +23,11 @@
};
// Keep in sync with package.json
Knex.VERSION = '0.1.6';
Knex.VERSION = '0.1.7';
var rethrower = function(err) {
throw err;
};
// Methods common to both the `Grammar` and `SchemaGrammar` interfaces,
// used to generate the sql in one form or another.
@ -40,13 +44,16 @@
// For those who dislike promise interfaces.
// Multiple calls to `exec` will resolve with the same value
// if called more than once.
// if called more than once. Any unhandled errors will be thrown
// after the last block.
exec: function(callback) {
this._promise || (this._promise = this.runQuery());
return this._promise.then(function(resp) {
callback(null, resp);
}, function(err) {
callback(err, null);
}).then(null, function(err) {
setTimeout(function() { throw err; }, 0);
});
},

View File

@ -1,6 +1,6 @@
{
"name": "knex",
"version": "0.1.6",
"version": "0.1.7",
"description": "A query builder for Postgres, MySQL and SQLite3, designed to be flexible, portable, and fun to use.",
"main": "knex.js",
"directories": {

View File

@ -1,4 +1,6 @@
var When = require('when');
var When = require('when');
var assert = require('assert');
module.exports = function(Knex, dbName, resolver) {
describe(dbName, function() {
@ -7,6 +9,25 @@ module.exports = function(Knex, dbName, resolver) {
Knex('accounts').select().then(resolver(ok), ok);
});
it('throws errors on the exec if uncaught in the last block', function(ok) {
var listeners = process.listeners('uncaughtException');
process.removeAllListeners('uncaughtException');
process.on('uncaughtException', function(err) {
process.removeAllListeners('uncaughtException');
for (var i = 0, l = listeners.length; i < l; i++) {
process.on('uncaughtException', listeners[i]);
}
ok();
});
Knex('accounts').select().exec(function(err, resp) {
console.log(undefinedVar);
});
});
it('uses `orderBy`', function(ok) {
Knex('accounts')
.select()