2013-09-13 16:58:38 -04:00
|
|
|
// Raw
|
|
|
|
// -------
|
2013-09-03 22:25:54 -04:00
|
|
|
(function(define) {
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
define(function(require, exports) {
|
2013-09-03 22:01:31 -04:00
|
|
|
|
|
|
|
var _ = require('underscore');
|
|
|
|
var Common = require('./common').Common;
|
|
|
|
|
2013-09-05 16:36:49 -04:00
|
|
|
var Raw = function(instance) {
|
2013-09-12 01:13:07 -04:00
|
|
|
this.knex = instance;
|
2013-09-12 01:00:44 -04:00
|
|
|
this.client = instance.client;
|
2013-09-13 11:40:51 -04:00
|
|
|
this.flags = {};
|
2013-09-03 22:01:31 -04:00
|
|
|
};
|
|
|
|
|
2013-09-05 16:36:49 -04:00
|
|
|
_.extend(Raw.prototype, Common, {
|
2013-09-03 22:01:31 -04:00
|
|
|
|
|
|
|
_source: 'Raw',
|
|
|
|
|
2013-09-05 16:36:49 -04:00
|
|
|
// Set the sql and the bindings associated with the query, returning
|
|
|
|
// the current raw object.
|
|
|
|
query: function(sql, bindings) {
|
|
|
|
this.bindings = _.isArray(bindings) ? bindings :
|
|
|
|
bindings ? [bindings] : [];
|
|
|
|
this.sql = sql;
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2013-09-03 22:01:31 -04:00
|
|
|
// Returns the raw sql for the query.
|
|
|
|
toSql: function() {
|
|
|
|
return this.sql;
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
exports.Raw = Raw;
|
2013-09-03 22:25:54 -04:00
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
})(
|
2013-09-05 16:36:49 -04:00
|
|
|
typeof define === 'function' && define.amd ? define : function (factory) { factory(require, exports); }
|
2013-09-03 22:25:54 -04:00
|
|
|
);
|