pqb 0.47.3 → 0.47.5

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/index.js CHANGED
@@ -563,7 +563,7 @@ const indexInnerToCode = (index, t) => {
563
563
  if (columnsMultiline) {
564
564
  const objects = [];
565
565
  for (const column of index.columns) {
566
- const expr = "column" in column ? column.column : column.expression;
566
+ const expr = "expression" in column ? column.expression : column.column;
567
567
  let hasOptions2 = false;
568
568
  for (const key in column) {
569
569
  if (key !== "column") {
@@ -574,7 +574,7 @@ const indexInnerToCode = (index, t) => {
574
574
  objects.push(`${orchidCore.singleQuote(expr)},`);
575
575
  } else {
576
576
  const props = [
577
- `${"column" in column ? "column" : "expression"}: ${orchidCore.singleQuote(
577
+ `${"expression" in column ? "expression" : "column"}: ${orchidCore.singleQuote(
578
578
  expr
579
579
  )},`
580
580
  ];
@@ -644,9 +644,11 @@ const excludeInnerToCode = (item, t) => {
644
644
  const hasOptions = optionsKeys.some((key) => key && item.options[key]);
645
645
  const objects = [];
646
646
  for (const column of item.columns) {
647
- const expr = "column" in column ? column.column : column.expression;
647
+ const expr = "expression" in column ? column.expression : column.column;
648
648
  const props = [
649
- `${"column" in column ? "column" : "expression"}: ${orchidCore.singleQuote(expr)},`
649
+ `${"expression" in column ? "expression" : "column"}: ${orchidCore.singleQuote(
650
+ expr
651
+ )},`
650
652
  ];
651
653
  for (const key of columnOptions) {
652
654
  const value = column[key];
@@ -768,12 +770,14 @@ const foreignKeyArgumentToCode = ({
768
770
  const columnIndexesToCode = (items) => {
769
771
  const code = [];
770
772
  for (const { options, name } of items) {
771
- orchidCore.addCode(code, `.${options.unique ? "unique" : "index"}(`);
773
+ orchidCore.addCode(
774
+ code,
775
+ `.${options.unique ? "unique" : "index"}(${name ? `${orchidCore.singleQuote(name)}` : ""}`
776
+ );
772
777
  const arr = [
773
778
  options.collate && `collate: ${orchidCore.singleQuote(options.collate)},`,
774
779
  options.opclass && `opclass: ${orchidCore.singleQuote(options.opclass)},`,
775
780
  options.order && `order: ${orchidCore.singleQuote(options.order)},`,
776
- name && `name: ${orchidCore.singleQuote(name)},`,
777
781
  options.using && `using: ${orchidCore.singleQuote(options.using)},`,
778
782
  options.include && `include: ${typeof options.include === "string" ? orchidCore.singleQuote(options.include) : `[${options.include.map(orchidCore.singleQuote).join(", ")}]`},`,
779
783
  options.nullsNotDistinct && `nullsNotDistinct: true,`,
@@ -782,7 +786,7 @@ const columnIndexesToCode = (items) => {
782
786
  options.where && `where: ${orchidCore.singleQuote(options.where)},`
783
787
  ].filter((x) => !!x);
784
788
  if (arr.length) {
785
- orchidCore.addCode(code, "{");
789
+ orchidCore.addCode(code, name ? `, {` : "{");
786
790
  orchidCore.addCode(code, arr);
787
791
  orchidCore.addCode(code, "}");
788
792
  }
@@ -3000,12 +3004,7 @@ const runAfterCommit = async (afterCommit, result) => {
3000
3004
  const applyBatchTransforms = (q, batches) => {
3001
3005
  if (q.transform) {
3002
3006
  for (const item of batches) {
3003
- item.parent[item.key] = orchidCore.applyTransforms(
3004
- q,
3005
- q.returnType,
3006
- q.transform,
3007
- item.data
3008
- );
3007
+ item.parent[item.key] = item.data === null ? void 0 : orchidCore.applyTransforms(q, q.returnType, q.transform, item.data);
3009
3008
  }
3010
3009
  }
3011
3010
  };