squel 6.0.6 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/esm/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // package.json
2
2
  var package_default = {
3
3
  name: "squel",
4
- version: "6.0.6",
4
+ version: "6.1.0",
5
5
  description: "SQL query string builder",
6
6
  keywords: [
7
7
  "sql",
@@ -289,7 +289,7 @@ function _buildSquel(flavour = null) {
289
289
  const customHandler = getValueHandler(value, this.options.valueHandlers, cls.globalValueHandlers);
290
290
  if (customHandler) {
291
291
  value = customHandler(value, asParam, formattingOptions);
292
- if (value && value.rawNesting) {
292
+ if (value?.rawNesting) {
293
293
  return { formatted: true, rawNesting: true, value: value.value };
294
294
  }
295
295
  }
@@ -340,7 +340,7 @@ function _buildSquel(flavour = null) {
340
340
  }
341
341
  _applyNestingFormatting(str, nesting = true) {
342
342
  if (str && typeof str === "string" && nesting && !this.options.rawNesting) {
343
- let alreadyHasBrackets = str.charAt(0) === "(" && str.charAt(str.length - 1) === ")";
343
+ let alreadyHasBrackets = str.startsWith("(") && str.endsWith(")");
344
344
  if (alreadyHasBrackets) {
345
345
  let idx = 0;
346
346
  let open = 1;
@@ -489,7 +489,7 @@ function _buildSquel(flavour = null) {
489
489
  name = this._sanitizeField(fieldName);
490
490
  }
491
491
  this._fieldName = name;
492
- this.options = _extend(Object.assign({}, cls.DefaultQueryBuilderOptions), options);
492
+ this.options = _extend({ ...cls.DefaultQueryBuilderOptions }, options);
493
493
  this._cases = [];
494
494
  }
495
495
  when(expression, ...values) {
@@ -539,7 +539,7 @@ function _buildSquel(flavour = null) {
539
539
  let obj = this;
540
540
  while (obj) {
541
541
  for (const prop of Object.getOwnPropertyNames(obj)) {
542
- if (prop !== "constructor" && typeof obj[prop] === "function" && prop.charAt(0) !== "_" && !cls.Block.prototype[prop]) {
542
+ if (prop !== "constructor" && typeof obj[prop] === "function" && !prop.startsWith("_") && !cls.Block.prototype[prop]) {
543
543
  ret[prop] = obj[prop];
544
544
  }
545
545
  }
@@ -705,7 +705,7 @@ function _buildSquel(flavour = null) {
705
705
  }
706
706
  if (!totalStr.length) {
707
707
  const fromTableBlock = queryBuilder?.getBlock(cls.FromTableBlock);
708
- if (fromTableBlock && fromTableBlock._hasTable()) {
708
+ if (fromTableBlock?._hasTable()) {
709
709
  totalStr = "*";
710
710
  }
711
711
  }
@@ -1177,7 +1177,7 @@ function _buildSquel(flavour = null) {
1177
1177
  return new this.constructor(this.options, blockClones);
1178
1178
  }
1179
1179
  getBlock(blockType) {
1180
- return this.blocks.filter((b) => b instanceof blockType)[0];
1180
+ return this.blocks.find((b) => b instanceof blockType);
1181
1181
  }
1182
1182
  };
1183
1183
  cls.Select = class extends cls.QueryBuilder {
@@ -1457,6 +1457,14 @@ squel.flavours.postgres = (_squel) => {
1457
1457
  };
1458
1458
  }
1459
1459
  };
1460
+ cls.UsingBlock = class extends cls.AbstractTableBlock {
1461
+ constructor(options) {
1462
+ super({ ...options, prefix: "USING" });
1463
+ }
1464
+ using(table, alias = null) {
1465
+ this._table(table, alias);
1466
+ }
1467
+ };
1460
1468
  cls.DistinctOnBlock = class extends cls.Block {
1461
1469
  _useDistinct = false;
1462
1470
  _distinctFields;
@@ -1539,6 +1547,7 @@ squel.flavours.postgres = (_squel) => {
1539
1547
  new cls.StringBlock(options, "DELETE"),
1540
1548
  new cls.TargetTableBlock(options),
1541
1549
  new cls.FromTableBlock({ ...options, singleTable: true }),
1550
+ new cls.UsingBlock(options),
1542
1551
  new cls.JoinBlock(options),
1543
1552
  new cls.WhereBlock(options),
1544
1553
  new cls.OrderByBlock(options),
@@ -1551,6 +1560,10 @@ squel.flavours.postgres = (_squel) => {
1551
1560
  };
1552
1561
 
1553
1562
  // src/mssql.ts
1563
+ var _limit = function(max) {
1564
+ max = this._sanitizeLimitOffset(max);
1565
+ this._parent._limits = max;
1566
+ };
1554
1567
  squel.flavours.mssql = (_squel) => {
1555
1568
  const cls = _squel.cls;
1556
1569
  cls.DefaultQueryBuilderOptions.replaceSingleQuotes = true;
@@ -1571,10 +1584,6 @@ squel.flavours.mssql = (_squel) => {
1571
1584
  super(options);
1572
1585
  this._limits = null;
1573
1586
  this._offsets = null;
1574
- const _limit = function(max) {
1575
- max = this._sanitizeLimitOffset(max);
1576
- this._parent._limits = max;
1577
- };
1578
1587
  this.ParentBlock = class extends cls.Block {
1579
1588
  _parent;
1580
1589
  constructor(parent) {
@@ -1781,4 +1790,4 @@ export {
1781
1790
  src_default as default
1782
1791
  };
1783
1792
 
1784
- //# debugId=3E1ABD59B2EE635A64756E2164756E21
1793
+ //# debugId=1734B424D7A11C2364756E2164756E21