Skip to content
This repository has been archived by the owner on Dec 20, 2023. It is now read-only.

Commit

Permalink
Merge pull request #90 from doug-martin/master
Browse files Browse the repository at this point in the history
v0.2.13
  • Loading branch information
doug-martin committed Jan 21, 2014
2 parents 39dda66 + a77f15d commit f9e4263
Show file tree
Hide file tree
Showing 10 changed files with 1,375 additions and 1,279 deletions.
5 changes: 5 additions & 0 deletions History.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# v0.2.13

* Updated `multiInsert` to support the returning of results.
* Updated the postgres adapter to not change strings with double `_` to identifiers.

# v0.2.12

* Patio migrate missingArgument undefined [#89](https://github.com/C2FO/patio/pull/89)
Expand Down
851 changes: 429 additions & 422 deletions docs-md/coverage.html

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions docs/History.html
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,11 @@



<h1>v0.2.13</h1>
<ul>
<li>Updated <code>multiInsert</code> to support the returning of results.</li>
<li>Updated the postgres adapter to not change strings with double <code>_</code> to identifiers.</li>
</ul>
<h1>v0.2.12</h1>
<ul>
<li>Patio migrate missingArgument undefined <a href="https://github.com/C2FO/patio/pull/89">#89</a></li>
Expand Down
851 changes: 429 additions & 422 deletions docs/coverage.html

Large diffs are not rendered by default.

79 changes: 37 additions & 42 deletions docs/patio_Dataset.html
Original file line number Diff line number Diff line change
Expand Up @@ -3342,7 +3342,7 @@ <h4>Actions</h4>
if (this.__columns) {
return asyncArray(this.__columns);
} else {
var ds = this.unfiltered().unordered().mergeOptions({distinct:null, limit:1});
var ds = this.unfiltered().unordered().mergeOptions({distinct: null, limit: 1});
return asyncArray(ds.forEach().chain(function () {
return (this.__columns = ds.__columns || []);
}.bind(this)));
Expand Down Expand Up @@ -3800,7 +3800,7 @@ <h3>
<em>Source</em>
<pre class="prettyprint linenums lang-js">
function (opts){
return merge({server:this.__opts.server || &quot;default&quot;}, opts || {});
return merge({server: this.__opts.server || &quot;default&quot;}, opts || {});

}
</pre>
Expand Down Expand Up @@ -7919,7 +7919,7 @@ <h3>
<em>Source</em>
<pre class="prettyprint linenums lang-js">
function (sql,opts){
return this.db.execute(sql, merge({server:this.__opts.server || &quot;readOnly&quot;}, opts || {}));
return this.db.execute(sql, merge({server: this.__opts.server || &quot;readOnly&quot;}, opts || {}));

}
</pre>
Expand Down Expand Up @@ -9621,46 +9621,43 @@ <h3>
opts = null;
}
opts = opts || {};
var ret;
var ret, self = this;
if (isInstanceOf(values, Dataset)) {
ret = this.db.transaction(hitch(this, function () {
return this.insert(columns, values);
}));
ret = this.db.transaction(function () {
return self.insert(columns, values);
});
} else {
ret = new Promise();
if (!values.length) {
ret.callback();
ret = new Promise().callback();
} else if (!columns.length) {
throw new QueryError(&quot;Invalid columns in import&quot;);
}
var sliceSize = opts.commitEvery || opts.slice;
var sliceSize = opts.commitEvery || opts.slice, result = [];
if (sliceSize) {
var offset = 0;
var execute = function () {
if (offset &gt;= values.length) {
ret.callback();
return;
}
this.db.transaction(opts, hitch(this, function () {
return when(this.multiInsertSql(columns, values.slice(offset, sliceSize + offset)).map(hitch(this, function (st) {
return this.executeDui(st);
})));
})).then(hitch(this, function () {
offset += sliceSize;
execute();
}), ret);
}.bind(this);
execute();
ret = asyncArray(partition(values, sliceSize)).forEach(function (entries, offset) {
offset = (offset * sliceSize);
return self.db.transaction(opts, function () {
return when(self.multiInsertSql(columns, entries).map(function (st, index) {
return self.executeDui(st).chain(function (res) {
result[offset + index] = res;
});
}));
});
}, 1);
} else {
var statements = this.multiInsertSql(columns, values);
ret = this.db.transaction(function () {
return when(statements.map(function (st) {
return this.executeDui(st);
}.bind(this)));
}.bind(this));
return when(statements.map(function (st, index) {
return self.executeDui(st).chain(function (res) {
result[index] = res;
});
}));
});
}
}
return ret.classic(cb).promise();
return ret.chain(function () {
return flatten(result);
}).classic(cb).promise();

}
</pre>
Expand Down Expand Up @@ -13599,9 +13596,9 @@ <h3>
this.__aggregateDataset()
.select(sql.min(this.stringToIdentifier(column)).as(&quot;v1&quot;), sql.max(this.stringToIdentifier(column)).as(&quot;v2&quot;))
.first()
.then(function (r) {
.chain(function (r) {
ret.callback(r.v1, r.v2);
}, ret);
}, ret.errback);
return ret.classic(cb).promise();

}
Expand Down Expand Up @@ -14807,7 +14804,7 @@ <h3>
<em>Source</em>
<pre class="prettyprint linenums lang-js">
function (cb){
return this.mergeOptions({limit:1}).all().chain(function (r) {
return this.mergeOptions({limit: 1}).all().chain(function (r) {
return r &amp;&amp; r.length ? r[0] : null;
}).classic(cb).promise();

Expand Down Expand Up @@ -15156,8 +15153,8 @@ <h3>
return r[c] || &quot;&quot;;
}).join(&quot;, &quot;));
}).chain(function () {
return vals.join(&quot;\r\n&quot;) + &quot;\r\n&quot;;
});
return vals.join(&quot;\r\n&quot;) + &quot;\r\n&quot;;
});
}.bind(this)).classic(cb).promise();

}
Expand Down Expand Up @@ -15241,13 +15238,11 @@ <h3>
valueColumn = null;
}
var k = this.__hashIdentifierToName(keyColumn), v = this.__hashIdentifierToName(valueColumn);
var mapPromise = this.map(function (r) {
return this.map(function (r) {
map[r[k]] = v ? r[v] : r;
});
mapPromise.then(function () {
ret.callback(map);
}, ret);
return ret.classic(cb).promise();
}).chain(function () {
return map;
}).classic(cb).promise();

}
</pre>
Expand Down
24 changes: 13 additions & 11 deletions lib/adapters/postgres.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,9 @@ var DS = define(Dataset, {
}), literal(ret))];
},

_literalString: function (v) {
return "'" + v.replace(/\\/g, "\\\\").replace(/'/g, "''") + "'";
},

_deleteFromSql: function () {
var self = this._static, space = self.SPACE;
Expand Down Expand Up @@ -610,8 +613,8 @@ var DB = define(Database, {
}
i.columns.push(r.column);
}).then(function () {
ret.callback(indexes);
}, ret);
ret.callback(indexes);
}, ret);
}, ret);

return ret.promise();
Expand Down Expand Up @@ -882,13 +885,13 @@ var DB = define(Database, {
expr = this.literal(toArray(cols));
}
switch (indexType) {
case "fullText":
expr = ["(to_tsvector(", this.literal(index.language || "simple"), ", ", this.literal(this.dataset.__fullTextStringJoin(cols)), "))"].join("");
indexType = "gin";
break;
case "spatial" :
indexType = "gist";
break;
case "fullText":
expr = ["(to_tsvector(", this.literal(index.language || "simple"), ", ", this.literal(this.dataset.__fullTextStringJoin(cols)), "))"].join("");
indexType = "gin";
break;
case "spatial" :
indexType = "gist";
break;
}
return ["CREATE", unique, "INDEX", this.__quoteIdentifier(indexName), "ON", this.__quoteSchemaTable(tableName), indexType ? "USING " + indexType : "", expr, filter ].join(" ");

Expand Down Expand Up @@ -984,5 +987,4 @@ var DB = define(Database, {
}

}
}).
as(exports, "PostgresDatabase");
}).as(exports, "PostgresDatabase");
Loading

0 comments on commit f9e4263

Please sign in to comment.