Comparing version 0.4.3 to 0.4.4
@@ -5,3 +5,3 @@ (function(exports) { | ||
function monologue(opt) { | ||
var dict = { escape: true }; | ||
var dict = { escape: true, sort_keys: false }; | ||
@@ -401,4 +401,7 @@ if( typeof opt === "undefined" ) { | ||
// grab the column names from the first object | ||
_g.columns = Object.keys( p[0] ).sort(); | ||
_g.columns = Object.keys( p[0] ); | ||
if( opt.sort_keys ) | ||
_g.columns.sort(); | ||
c.push( _g.columns.join(', ') ); | ||
@@ -421,4 +424,9 @@ } | ||
else { | ||
var col = _g.columns || Object.keys( p ).sort(); | ||
var col = _g.columns || Object.keys( p ); | ||
// if _g.columns is set, it's already sorted (if sorting) | ||
if( opt.sort_keys && typeof _g.columns === "undefined" ) { | ||
col.sort(); | ||
} | ||
for( var jj = 0, len = col.length; jj < len; ++jj ) { | ||
@@ -480,3 +488,3 @@ // matching a column to a set, i.e. {id: [1,2,3,4]} | ||
switch( typeof v ) { | ||
case 'boolean': return (v) ? 'true' : 'false'; | ||
case 'boolean': return (v ? 'true' : 'false'); | ||
case 'number': return v + ''; | ||
@@ -483,0 +491,0 @@ } |
{ | ||
"name": "monologue", | ||
"version": "0.4.3", | ||
"version": "0.4.4", | ||
"description": "Streamlined MySQL query building", | ||
@@ -5,0 +5,0 @@ "main": "./monologue.js", |
@@ -6,2 +6,6 @@ Monologue - Streamlined query building | ||
**Breaking Change Coming** | ||
Bound parameter-style queries will be removed in 0.5.0. Documentation has been removed for quite a while, so this should affect very few, if any, users. | ||
**Cool New Features** | ||
@@ -11,12 +15,4 @@ | ||
monologue.where() was update to handle arrays as a grouping mechanism. An array of objects will be separated by OR, where an objects properties will be separated by AND. See examples below. | ||
monologue.where() was updated to handle arrays as a grouping mechanism. An array of objects will be separated by OR, where an objects properties will be separated by AND. See examples below. | ||
**Breaking Change** | ||
The behavior of monologue.backquote() was changed for objects in v0.4.0. It now returns a copy of the object with the property names backquoted, rather than an array of the property names. See examples below. | ||
Test your SQL output! It is possible bugs may exist which could result in unsafe SQL statements. Please report bugs to the github repository | ||
This library is not necessarily exhaustive in representing MySQL, so if there are language features you would like to see added, submit a request or pull request on github. | ||
**Install** | ||
@@ -23,0 +19,0 @@ |
399
17197
164