mirror of
https://github.com/knex/knex.git
synced 2025-07-04 07:26:21 +00:00
26 lines
775 B
JavaScript
26 lines
775 B
JavaScript
![]() |
|
||
|
var _ = require('lodash');
|
||
|
|
||
|
// Push a new query onto the compiled "sequence" stack,
|
||
|
// creating a new formatter, returning the compiler.
|
||
|
exports.pushQuery = function(query) {
|
||
|
if (!query) return;
|
||
|
if (_.isString(query)) {
|
||
|
query = {sql: query};
|
||
|
} else {
|
||
|
query = query;
|
||
|
}
|
||
|
if (!query.bindings) {
|
||
|
query.bindings = this.formatter.bindings;
|
||
|
}
|
||
|
this.sequence.push(query);
|
||
|
this.formatter = this.client.formatter();
|
||
|
};
|
||
|
|
||
|
// Used in cases where we need to push some additional column specific statements.
|
||
|
exports.pushAdditional = function(fn) {
|
||
|
var child = new this.constructor(this.client, this.tableCompiler, this.columnBuilder);
|
||
|
fn.call(child, _.rest(arguments));
|
||
|
this.sequence.additional = (this.sequence.additional || []).concat(child.sequence);
|
||
|
};
|