release 0.6.19

This commit is contained in:
Tim Griesser 2014-06-27 11:59:54 -04:00
parent 295f57d296
commit 1a438e3d41
5 changed files with 119 additions and 32 deletions

View File

@ -1,5 +1,5 @@
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.Knex=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
// Knex.js 0.6.18
// Knex.js 0.6.19
// --------------
// (c) 2014 Tim Griesser
@ -78,7 +78,7 @@ Knex.initialize = function(config) {
// The `__knex__` is used if you need to duck-type check whether this
// is a knex builder, without a full on `instanceof` check.
knex.VERSION = knex.__knex__ = '0.6.18';
knex.VERSION = knex.__knex__ = '0.6.19';
knex.raw = function(sql, bindings) {
return new client.Raw(sql, bindings);
};
@ -1256,7 +1256,7 @@ Client_MySQL2.prototype.initRunner = function() {
// Get a raw connection, called by the `pool` whenever a new
// connection needs to be added to the pool.
Client_MySQL2.prototype.acquireRawConnection = function() {
var connection = mysql2.createConnection(_.pick(this.connectionSettings, 'user', 'database', 'connection'));
var connection = mysql2.createConnection(_.pick(this.connectionSettings, configOptions));
return new Promise(function(resolver, rejecter) {
connection.connect(function(err) {
if (err) return rejecter(err);
@ -1265,6 +1265,8 @@ Client_MySQL2.prototype.acquireRawConnection = function() {
});
};
var configOptions = ['user', 'database', 'host', 'password', 'ssl', 'connection', 'stream'];
module.exports = Client_MySQL2;
},{"../../promise":53,"../mysql":6,"./runner":19,"inherits":"oxw+vU","lodash":"K2RcUv"}],19:[function(_dereq_,module,exports){
// MySQL Runner
@ -3453,9 +3455,6 @@ function QueryBuilder() {
}
inherits(QueryBuilder, EventEmitter);
// Valid values for the `order by` clause generation.
var orderBys = ['asc', 'desc'];
QueryBuilder.prototype.toString = function() {
return this.toQuery();
};
@ -3806,27 +3805,51 @@ QueryBuilder.prototype.orWhereNotBetween = function(column, values) {
};
// Adds a `group by` clause to the query.
QueryBuilder.prototype.groupBy = function() {
QueryBuilder.prototype.groupBy = function(item) {
if (item instanceof Raw) {
return this.groupByRaw.apply(this, arguments);
}
this._statements.push({
grouping: 'group',
type: 'groupByBasic',
value: helpers.normalizeArr.apply(null, arguments)
});
return this;
};
// Adds a raw `group by` clause to the query.
QueryBuilder.prototype.groupByRaw = function(sql, bindings) {
var raw = (sql instanceof Raw ? sql : new Raw(sql, bindings));
this._statements.push({
grouping: 'group',
type: 'groupByRaw',
value: raw
});
return this;
};
// Adds a `order by` clause to the query.
QueryBuilder.prototype.orderBy = function(column, direction) {
if (!(direction instanceof Raw)) {
if (!_.contains(orderBys, (direction || '').toLowerCase())) direction = 'asc';
}
this._statements.push({
grouping: 'order',
type: 'orderByBasic',
value: column,
direction: direction
});
return this;
};
// Add a raw `order by` clause to the query.
QueryBuilder.prototype.orderByRaw = function(sql, bindings) {
var raw = (sql instanceof Raw ? sql : new Raw(sql, bindings));
this._statements.push({
grouping: 'order',
type: 'orderByRaw',
value: raw
});
return this;
};
// Add a union statement to the query.
QueryBuilder.prototype.union = function(callback, wrap) {
if (arguments.length > 1) {
@ -4363,10 +4386,14 @@ QueryCompiler.prototype._groupsOrders = function(type) {
if (!items) return '';
var sql = [];
for (var i = 0, l = items.length; i < l; i++) {
var item = items[i];
var str = this.formatter.columnize(item.value);
if (type === 'order') {
str += ' ' + this.formatter.direction(item.direction);
var str, item = items[i];
if (item.value instanceof Raw) {
str = this.formatter.checkRaw(item.value);
} else {
str = this.formatter.columnize(item.value);
if (type === 'order') {
str += ' ' + this.formatter.direction(item.direction);
}
}
sql.push(str);
}
@ -4571,7 +4598,9 @@ module.exports = [
'orWhereBetween',
'orWhereNotBetween',
'groupBy',
'groupByRaw',
'orderBy',
'orderByRaw',
'union',
'unionAll',
'having',

View File

@ -1,5 +1,5 @@
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.Knex=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
// Knex.js 0.6.18
// Knex.js 0.6.19
// --------------
// (c) 2014 Tim Griesser
@ -78,7 +78,7 @@ Knex.initialize = function(config) {
// The `__knex__` is used if you need to duck-type check whether this
// is a knex builder, without a full on `instanceof` check.
knex.VERSION = knex.__knex__ = '0.6.18';
knex.VERSION = knex.__knex__ = '0.6.19';
knex.raw = function(sql, bindings) {
return new client.Raw(sql, bindings);
};
@ -1730,9 +1730,6 @@ function QueryBuilder() {
}
inherits(QueryBuilder, EventEmitter);
// Valid values for the `order by` clause generation.
var orderBys = ['asc', 'desc'];
QueryBuilder.prototype.toString = function() {
return this.toQuery();
};
@ -2083,27 +2080,51 @@ QueryBuilder.prototype.orWhereNotBetween = function(column, values) {
};
// Adds a `group by` clause to the query.
QueryBuilder.prototype.groupBy = function() {
QueryBuilder.prototype.groupBy = function(item) {
if (item instanceof Raw) {
return this.groupByRaw.apply(this, arguments);
}
this._statements.push({
grouping: 'group',
type: 'groupByBasic',
value: helpers.normalizeArr.apply(null, arguments)
});
return this;
};
// Adds a raw `group by` clause to the query.
QueryBuilder.prototype.groupByRaw = function(sql, bindings) {
var raw = (sql instanceof Raw ? sql : new Raw(sql, bindings));
this._statements.push({
grouping: 'group',
type: 'groupByRaw',
value: raw
});
return this;
};
// Adds a `order by` clause to the query.
QueryBuilder.prototype.orderBy = function(column, direction) {
if (!(direction instanceof Raw)) {
if (!_.contains(orderBys, (direction || '').toLowerCase())) direction = 'asc';
}
this._statements.push({
grouping: 'order',
type: 'orderByBasic',
value: column,
direction: direction
});
return this;
};
// Add a raw `order by` clause to the query.
QueryBuilder.prototype.orderByRaw = function(sql, bindings) {
var raw = (sql instanceof Raw ? sql : new Raw(sql, bindings));
this._statements.push({
grouping: 'order',
type: 'orderByRaw',
value: raw
});
return this;
};
// Add a union statement to the query.
QueryBuilder.prototype.union = function(callback, wrap) {
if (arguments.length > 1) {
@ -2640,10 +2661,14 @@ QueryCompiler.prototype._groupsOrders = function(type) {
if (!items) return '';
var sql = [];
for (var i = 0, l = items.length; i < l; i++) {
var item = items[i];
var str = this.formatter.columnize(item.value);
if (type === 'order') {
str += ' ' + this.formatter.direction(item.direction);
var str, item = items[i];
if (item.value instanceof Raw) {
str = this.formatter.checkRaw(item.value);
} else {
str = this.formatter.columnize(item.value);
if (type === 'order') {
str += ' ' + this.formatter.direction(item.direction);
}
}
sql.push(str);
}
@ -2848,7 +2873,9 @@ module.exports = [
'orWhereBetween',
'orWhereNotBetween',
'groupBy',
'groupByRaw',
'orderBy',
'orderByRaw',
'union',
'unionAll',
'having',

View File

@ -32,7 +32,7 @@
<div id="sidebar" class="interface">
<a class="toc_title" href="#">
Knex.js <span class="version">(0.6.18)</span>
Knex.js <span class="version">(0.6.19)</span>
</a>
<ul class="toc_section">
<li>&raquo; <a href="https://github.com/tgriesser/knex">GitHub Repository</a></li>
@ -96,7 +96,9 @@
<li> <a href="#Builder-distinct">distinct</a></li>
<li> <a href="#Builder-groupBy">groupBy</a></li>
<li> <a href="#Builder-groupByRaw">groupByRaw</a></li>
<li> <a href="#Builder-orderBy">orderBy</a></li>
<li> <a href="#Builder-orderByRaw">orderByRaw</a></li>
<li> <a href="#Builder-having">having</a></li>
<li> <a href="#Builder-offset">offset</a></li>
<li> <a href="#Builder-limit">limit</a></li>
@ -296,7 +298,7 @@
</p>
<h2>Latest Release: 0.6.18 - <span class="small"><a href="#changelog">Change Log</a></span></h2>
<h2>Latest Release: 0.6.19 - <span class="small"><a href="#changelog">Change Log</a></span></h2>
<p>
Current Develop &mdash;
@ -879,6 +881,16 @@ knex('customers')
<pre class="display">
knex('users').groupBy('count')
</pre>
<p id="Builder-groupByRaw">
<b class="header">groupByRaw</b><code>.groupBy(sql)</code>
<br />
Adds a raw <tt>group by</tt> clause to the query.
</p>
<pre class="display">
knex.select('year', knex.raw('SUM(profit)')).from('sales').groupByRaw('year WITH ROLLUP')
</pre>
<p id="Builder-orderBy">
@ -889,6 +901,16 @@ knex('users').groupBy('count')
<pre class="display">
knex('users').orderBy('name', 'desc')
</pre>
<p id="Builder-orderByRaw">
<b class="header">orderByRaw</b><code>.orderByRaw(sql)</code>
<br />
Adds an <tt>order by raw</tt> clause to the query.
</p>
<pre class="display">
knex.select('*').from('table').orderByRaw('col NULLS LAST DESC')
</pre>
<p id="Builder-having">
@ -2245,6 +2267,15 @@ $ npm test
<h2 id="changelog">Change Log</h2>
<p>
<b class="header">0.6.19</b> &mdash; <small><i>June 27, 2014</i></small><br />
</p>
<ul>
<li>Add <tt>groupByRaw</tt> / <tt>orderByRaw</tt> methods, better support for raw statements in group / order (#282).</li>
<li>Support more config options for node-mysql2 dialect (#341).</li>
<li>CLI help text fix, (#342).</li>
</ul>
<p>
<b class="header">0.6.18</b> &mdash; <small><i>June 25, 2014</i></small><br />
Patch for the <a href="#Streams-stream">method</a>, calling without a handler should return the stream, not a promise (#337).

View File

@ -1,4 +1,4 @@
// Knex.js 0.6.18
// Knex.js 0.6.19
// --------------
// (c) 2014 Tim Griesser
@ -77,7 +77,7 @@ Knex.initialize = function(config) {
// The `__knex__` is used if you need to duck-type check whether this
// is a knex builder, without a full on `instanceof` check.
knex.VERSION = knex.__knex__ = '0.6.18';
knex.VERSION = knex.__knex__ = '0.6.19';
knex.raw = function(sql, bindings) {
return new client.Raw(sql, bindings);
};

View File

@ -1,6 +1,6 @@
{
"name": "knex",
"version": "0.6.18",
"version": "0.6.19",
"description": "A batteries-included SQL query & schema builder for Postgres, MySQL and SQLite3 and the Browser",
"main": "knex.js",
"directories": {