pqb 0.18.27 → 0.18.29

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
@@ -3192,7 +3192,7 @@ class CitextColumn extends TextBaseColumn {
3192
3192
  }
3193
3193
 
3194
3194
  const dateTimeEncode = (input) => {
3195
- return typeof input === "object" ? input : new Date(input);
3195
+ return typeof input === "number" ? new Date(input) : input;
3196
3196
  };
3197
3197
  const skipDateMethodsFromToCode = { encodeFn: dateTimeEncode };
3198
3198
  const parseToNumber = (value) => value ? Date.parse(value) : value;
@@ -3278,10 +3278,12 @@ class TimestampTZColumn extends DateTimeTzBaseClass {
3278
3278
  return timestampToCode(this, t);
3279
3279
  }
3280
3280
  }
3281
- class TimeColumn extends DateTimeBaseClass {
3282
- constructor() {
3283
- super(...arguments);
3281
+ class TimeColumn extends ColumnType {
3282
+ constructor(dateTimePrecision) {
3283
+ super();
3284
3284
  this.dataType = "time";
3285
+ this.operators = Operators.time;
3286
+ this.data.dateTimePrecision = dateTimePrecision;
3285
3287
  }
3286
3288
  toCode(t) {
3287
3289
  const { dateTimePrecision } = this.data;
@@ -3294,6 +3296,7 @@ class TimeColumn extends DateTimeBaseClass {
3294
3296
  );
3295
3297
  }
3296
3298
  }
3299
+ assignMethodsToClass(TimeColumn, dateTypeMethods);
3297
3300
  class IntervalColumn extends ColumnType {
3298
3301
  constructor(fields, precision) {
3299
3302
  super();
@@ -9588,11 +9591,27 @@ class QueryMethods {
9588
9591
  *
9589
9592
  * ```ts
9590
9593
  * // Select the category and sum of prices grouped by the category
9591
- * const results = Product.select('category')
9594
+ * const results = db.product
9595
+ * .select('category')
9592
9596
  * .selectSum('price', { as: 'sumPrice' })
9593
9597
  * .group('category');
9594
9598
  * ```
9595
9599
  *
9600
+ * Also, it's possible to group by a selected value:
9601
+ *
9602
+ * ```ts
9603
+ * const results = db.product
9604
+ * .select({
9605
+ * month: db.product.sql`extract(month from "createdAt")`.type((t) =>
9606
+ * // month is returned as string, parse it to int
9607
+ * t.string().parse(parseInt),
9608
+ * ),
9609
+ * })
9610
+ * .selectSum('price', { as: 'sumPrice' })
9611
+ * // group by month extracted from "createdAt"
9612
+ * .group('month');
9613
+ * ```
9614
+ *
9596
9615
  * @param columns - column names or a raw SQL
9597
9616
  */
9598
9617
  group(...columns) {