helpers.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. 'use strict';
  2. exports.__esModule = true;
  3. var _tail2 = require('lodash/tail');
  4. var _tail3 = _interopRequireDefault(_tail2);
  5. var _isString2 = require('lodash/isString');
  6. var _isString3 = _interopRequireDefault(_isString2);
  7. exports.pushQuery = pushQuery;
  8. exports.pushAdditional = pushAdditional;
  9. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  10. // Push a new query onto the compiled "sequence" stack,
  11. // creating a new formatter, returning the compiler.
  12. function pushQuery(query) {
  13. if (!query) return;
  14. if ((0, _isString3.default)(query)) {
  15. query = { sql: query };
  16. }
  17. if (!query.bindings) {
  18. query.bindings = this.formatter.bindings;
  19. }
  20. this.sequence.push(query);
  21. this.formatter = this.client.formatter();
  22. }
  23. // Used in cases where we need to push some additional column specific statements.
  24. function pushAdditional(fn) {
  25. var child = new this.constructor(this.client, this.tableCompiler, this.columnBuilder);
  26. fn.call(child, (0, _tail3.default)(arguments));
  27. this.sequence.additional = (this.sequence.additional || []).concat(child.sequence);
  28. }