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.mjs CHANGED
@@ -2931,16 +2931,28 @@ class ArrayColumn extends ColumnType {
2931
2931
  hideFromCode: true
2932
2932
  }
2933
2933
  );
2934
- this.data.item = item;
2934
+ item.data.isNullable = true;
2935
+ this.data.item = item instanceof ArrayColumn ? item.data.item : item;
2935
2936
  this.data.name = item.data.name;
2937
+ this.data.arrayDims = item instanceof ArrayColumn ? item.data.arrayDims + 1 : 1;
2936
2938
  }
2937
2939
  toSQL() {
2938
- return `${this.data.item.toSQL()}[]`;
2940
+ return this.data.item.toSQL() + "[]".repeat(this.data.arrayDims);
2939
2941
  }
2940
2942
  toCode(t, m) {
2941
- const code = ["array("];
2942
- addCode(code, this.data.item.toCode(t));
2943
- addCode(code, `)${arrayDataToCode(this.data, m)}`);
2943
+ let open = "array(";
2944
+ let close = ")";
2945
+ for (let i = 1; i < this.data.arrayDims; i++) {
2946
+ open += `${t}.array(`;
2947
+ close += ")";
2948
+ }
2949
+ const code = [open];
2950
+ const { item } = this.data;
2951
+ const { isNullable } = item.data;
2952
+ delete item.data.isNullable;
2953
+ addCode(code, item.toCode(t));
2954
+ item.data.isNullable = isNullable;
2955
+ addCode(code, `${close}${arrayDataToCode(this.data, m)}`);
2944
2956
  return columnCode(this, t, code, m);
2945
2957
  }
2946
2958
  }