pqb 0.36.6 → 0.36.7

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.d.ts CHANGED
@@ -2634,6 +2634,7 @@ interface ArrayColumnValue {
2634
2634
  }
2635
2635
  interface ArrayData<Item extends ArrayColumnValue> extends ColumnData, ArrayMethodsData {
2636
2636
  item: Item;
2637
+ arrayDims: number;
2637
2638
  }
2638
2639
  declare class ArrayColumn<Schema extends ColumnTypeSchemaArg, Item extends ArrayColumnValue, InputType, OutputType, QueryType> extends ColumnType<Schema, Item['type'][], InputType, OperatorsArray, Item['inputType'][], Item['outputType'][], OutputType, Item['queryType'][], QueryType> {
2639
2640
  dataType: "array";
package/dist/index.js CHANGED
@@ -2933,16 +2933,28 @@ class ArrayColumn extends ColumnType {
2933
2933
  hideFromCode: true
2934
2934
  }
2935
2935
  );
2936
- this.data.item = item;
2936
+ item.data.isNullable = true;
2937
+ this.data.item = item instanceof ArrayColumn ? item.data.item : item;
2937
2938
  this.data.name = item.data.name;
2939
+ this.data.arrayDims = item instanceof ArrayColumn ? item.data.arrayDims + 1 : 1;
2938
2940
  }
2939
2941
  toSQL() {
2940
- return `${this.data.item.toSQL()}[]`;
2942
+ return this.data.item.toSQL() + "[]".repeat(this.data.arrayDims);
2941
2943
  }
2942
2944
  toCode(t, m) {
2943
- const code = ["array("];
2944
- orchidCore.addCode(code, this.data.item.toCode(t));
2945
- orchidCore.addCode(code, `)${orchidCore.arrayDataToCode(this.data, m)}`);
2945
+ let open = "array(";
2946
+ let close = ")";
2947
+ for (let i = 1; i < this.data.arrayDims; i++) {
2948
+ open += `${t}.array(`;
2949
+ close += ")";
2950
+ }
2951
+ const code = [open];
2952
+ const { item } = this.data;
2953
+ const { isNullable } = item.data;
2954
+ delete item.data.isNullable;
2955
+ orchidCore.addCode(code, item.toCode(t));
2956
+ item.data.isNullable = isNullable;
2957
+ orchidCore.addCode(code, `${close}${orchidCore.arrayDataToCode(this.data, m)}`);
2946
2958
  return columnCode(this, t, code, m);
2947
2959
  }
2948
2960
  }