From 6919c9586d68f6fd9baacea0b8bc21d6eb9beb7b Mon Sep 17 00:00:00 2001
From: Tim Griesser 
Date: Mon, 14 Oct 2013 08:17:05 -0400
Subject: [PATCH] documentation updates for 0.4.10 release
---
 docs/assets/behavior.js                      |  4 +-
 docs/clients/base/grammar.html               | 11 ++-
 docs/clients/base/sqlite3/grammar.html       |  3 +-
 docs/clients/pool.html                       | 31 +++++----
 docs/clients/server/mysql/grammar.html       |  2 +
 docs/clients/server/mysql/schemagrammar.html |  4 +-
 docs/knex.html                               |  4 +-
 docs/lib/common.html                         |  9 ++-
 docs/lib/schemabuilder.html                  |  8 +++
 index.html                                   | 71 +++++++++++++++++---
 knex.js                                      |  4 +-
 11 files changed, 116 insertions(+), 35 deletions(-)
diff --git a/docs/assets/behavior.js b/docs/assets/behavior.js
index 3ce0f727..46141d05 100644
--- a/docs/assets/behavior.js
+++ b/docs/assets/behavior.js
@@ -545,8 +545,8 @@ f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3
           "type": "heading",
           "data": {
             "level": 2,
-            "title": "Knex.js  0.4.9",
-            "slug": "knexjs-049"
+            "title": "Knex.js  0.4.10",
+            "slug": "knexjs-0410"
           },
           "depth": 2
         }
diff --git a/docs/clients/base/grammar.html b/docs/clients/base/grammar.html
index 5213226f..0b4c7c14 100644
--- a/docs/clients/base/grammar.html
+++ b/docs/clients/base/grammar.html
@@ -33,14 +33,17 @@ to keep the interface database agnostic.
    compileSelect: function(qb) {
-      var sql = {};
+      var sql = [];
       if (_.isEmpty(qb.columns)) qb.columns = ['*'];
       for (var i = 0, l = components.length; i < l; i++) {
         var component = components[i];
         var result = _.result(qb, component);
         if (result != null) {
-          sql[component] = this['compile' + Helpers.capitalize(component)](qb, result);
+          sql.push(this['compile' + Helpers.capitalize(component)](qb, result));
         }
+      }
      if (qb.transaction && qb.flags.selectMode) {
+        sql.push(this['compile' + qb.flags.selectMode](qb));
       }
       return _.compact(sql).join(' ');
     },
    compileAggregate: function(qb) {
@@ -180,6 +183,10 @@ query to be used for insert and update without issue.<
       return 'delete from ' + table + ' ' + where;
     },
    compileTruncate: function(qb) {
       return 'truncate ' + this.wrapTable(qb.table);
+    },
    compileForUpdate: function() {
+      return 'for update';
+    },
    compileForShare: function() {
+      return 'for share';
     },
    wrap: function(value) {
       var segments;
diff --git a/docs/clients/base/sqlite3/grammar.html b/docs/clients/base/sqlite3/grammar.html
index 194893ad..eafc9e5b 100644
--- a/docs/clients/base/sqlite3/grammar.html
+++ b/docs/clients/base/sqlite3/grammar.html
@@ -49,7 +49,8 @@ then join them all together with select unions to complete the queries.
sql
.push('delete from sqlite_sequence where name = ' + table);
       sql.push('delete from ' + table);
       return sql;
-    
}
+    
},    compileForUpdate: function() {},
+    compileForShare:  function() {}
 
   }, baseGrammar);
 
diff --git a/docs/clients/pool.html b/docs/clients/pool.html
index 92bf5af5..dff4c612 100644
--- a/docs/clients/pool.html
+++ b/docs/clients/pool.html
@@ -16,29 +16,30 @@ the pool if it doesn't already exist.
_.bindAll(this, 'acquire', 'release');
     this.config = config;
     this.client = client;
+    if (!config || !client) {
+      throw new Error('The config and client are required to use the pool module.');
+    }
     this.init();
   };
 
-  Pool.prototype = {
    defaults: function() {
-      var poolInstance = this;
+  Pool.prototype = {
    defaults: function() {
+      var pool = this;
       return {
         min: 2,
         max: 10,
         create: function(callback) {
-          var promise = poolInstance.client.getRawConnection()
+          var promise = pool.client.getRawConnection()
             .tap(function(connection) {
               connection.__cid = _.uniqueId('__cid');
-              if (poolInstance.config.afterCreate) {
-                return nodefn.call(poolInstance.config.afterCreate, connection);
+              if (pool.config.afterCreate) {
+                return nodefn.call(pool.config.afterCreate, connection);
               }
             });
           return nodefn.bindCallback(promise, callback);
         },
         destroy: function(connection) {
-          if (poolInstance.config.beforeDestroy) {
-            return poolInstance.config.beforeDestroy(connection, function() {
+          if (pool.config.beforeDestroy) {
+            return pool.config.beforeDestroy(connection, function() {
               connection.end();
             });
           }
@@ -57,10 +58,14 @@ options passed into the constructor.
this.poolInstance.release(connection, callback);
     },
    destroy: function(callback) {
       var poolInstance = this.poolInstance;
-      poolInstance.drain(function() {
-        poolInstance.destroyAllNow(callback);
-      });
-      delete this.poolInstance;
+      if (poolInstance) {
+        poolInstance.drain(function() {
+          poolInstance.destroyAllNow(callback);
+        });
+        delete this.poolInstance;
+      } else {
+        callback();
+      }
       return this;
     }
 
diff --git a/docs/clients/server/mysql/grammar.html b/docs/clients/server/mysql/grammar.html
index 89613f4e..2073b5ef 100644
--- a/docs/clients/server/mysql/grammar.html
+++ b/docs/clients/server/mysql/grammar.html
@@ -8,6 +8,8 @@
     if (builder.type === 'insert') response = [response.insertId];
     if (builder.type === 'delete' || builder.type === 'update') response = response.affectedRows;
     return response;
+  },
  compileForShare: function() {
+    return 'lock in share mode';
   }
 
 }, baseGrammar);
Compiles the
selectstatement, or nested sub-selects by calling each of the component compilers, trimming out the empties, and returning a generated query string.