Fix an issue with multiple group by columns
This commit is contained in:
parent
3c5ed1e58a
commit
a1ad4caea4
@ -2,6 +2,8 @@
|
||||
|
||||
A node query builder for various SQL databases, based on CodeIgniter's query builder.
|
||||
|
||||
[![Build Status](https://travis-ci.org/timw4mail/node-query.svg?branch=master)](https://travis-ci.org/timw4mail/node-query)
|
||||
|
||||
### Basic use
|
||||
|
||||
var nodeQuery = require('node-query');
|
||||
|
@ -93,6 +93,7 @@
|
||||
|
||||
<section class="readme-section">
|
||||
<article><h1>Node-query</h1><p>A node query builder for various SQL databases, based on CodeIgniter's query builder.</p>
|
||||
<p><a href="https://travis-ci.org/timw4mail/node-query"><img src="https://travis-ci.org/timw4mail/node-query.svg?branch=master" alt="Build Status"></a></p>
|
||||
<h3>Basic use</h3><pre class="prettyprint source"><code>var nodeQuery = require('node-query');
|
||||
|
||||
var connection = ... // Database module connection
|
||||
|
@ -273,8 +273,8 @@ var QueryBuilder = function(driver, adapter) {
|
||||
{
|
||||
sql = _p.compile(type, table);
|
||||
}
|
||||
//console.log(sql);
|
||||
//console.log('------------------------');
|
||||
console.log(sql);
|
||||
console.log('------------------------');
|
||||
|
||||
if ( ! vals)
|
||||
{
|
||||
@ -621,10 +621,10 @@ var QueryBuilder = function(driver, adapter) {
|
||||
* @return this
|
||||
*/
|
||||
this.groupBy = function(field) {
|
||||
if (Array.isArray(field))
|
||||
if ( ! helpers.isScalar(field))
|
||||
{
|
||||
var newGroupArray = field.map(driver.quoteIdentifiers);
|
||||
state.groupArray.concat(newGroupArray);
|
||||
state.groupArray = state.groupArray.concat(newGroupArray);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -185,7 +185,8 @@ module.exports = (function() {
|
||||
.from('create_test')
|
||||
.where('id >', 0)
|
||||
.where('id <', 9000)
|
||||
.groupBy('id')
|
||||
.groupBy('k')
|
||||
.groupBy(['id', 'val'])
|
||||
.orderBy('id', 'DESC')
|
||||
.orderBy('k', "ASC")
|
||||
.limit(5, 2)
|
||||
|
Loading…
Reference in New Issue
Block a user