orchid-orm 1.5.30 → 1.5.31

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
@@ -192,7 +192,7 @@ declare const createBaseTable: <CT extends ColumnTypesBase>(options?: {
192
192
  xml: () => pqb.XMLColumn;
193
193
  json: <Type extends pqb.JSONTypeAny>(schemaOrFn: Type | ((j: {
194
194
  set: <Value extends pqb.JSONTypeAny>(valueType: Value) => pqb.JSONSet<Value>;
195
- tuple: <T_1 extends pqb.JSONTupleItems | [], Rest extends pqb.JSONTypeAny | null = null>(items: T_1, rest?: Rest) => pqb.JSONTuple<T_1, Rest>;
195
+ tuple: <T_1 extends [] | pqb.JSONTupleItems, Rest extends pqb.JSONTypeAny | null = null>(items: T_1, rest?: Rest) => pqb.JSONTuple<T_1, Rest>;
196
196
  union: <T_2 extends [pqb.JSONTypeAny, pqb.JSONTypeAny, ...pqb.JSONTypeAny[]]>(types: T_2) => pqb.JSONUnion<T_2>;
197
197
  any: () => pqb.JSONAny;
198
198
  bigint: () => pqb.JSONBigInt;
@@ -230,12 +230,8 @@ declare const createBaseTable: <CT extends ColumnTypesBase>(options?: {
230
230
  timestamps: <T_14 extends pqb.ColumnType<unknown, pqb.BaseOperators, unknown>>(this: {
231
231
  timestamp(): T_14;
232
232
  }) => {
233
- createdAt: T_14 & {
234
- hasDefault: true;
235
- };
236
- updatedAt: T_14 & {
237
- hasDefault: true;
238
- };
233
+ createdAt: pqb.ColumnWithDefault<T_14, pqb.RawExpression<pqb.ColumnTypeBase<unknown, pqb.BaseOperators, unknown, pqb.ColumnDataBase>>>;
234
+ updatedAt: pqb.ColumnWithDefault<T_14, pqb.RawExpression<pqb.ColumnTypeBase<unknown, pqb.BaseOperators, unknown, pqb.ColumnDataBase>>>;
239
235
  };
240
236
  primaryKey(columns: string[], options?: {
241
237
  name?: string | undefined;
@@ -292,7 +288,7 @@ declare const createBaseTable: <CT extends ColumnTypesBase>(options?: {
292
288
  xml: () => pqb.XMLColumn;
293
289
  json: <Type extends pqb.JSONTypeAny>(schemaOrFn: Type | ((j: {
294
290
  set: <Value extends pqb.JSONTypeAny>(valueType: Value) => pqb.JSONSet<Value>;
295
- tuple: <T_1 extends pqb.JSONTupleItems | [], Rest extends pqb.JSONTypeAny | null = null>(items: T_1, rest?: Rest) => pqb.JSONTuple<T_1, Rest>;
291
+ tuple: <T_1 extends [] | pqb.JSONTupleItems, Rest extends pqb.JSONTypeAny | null = null>(items: T_1, rest?: Rest) => pqb.JSONTuple<T_1, Rest>;
296
292
  union: <T_2 extends [pqb.JSONTypeAny, pqb.JSONTypeAny, ...pqb.JSONTypeAny[]]>(types: T_2) => pqb.JSONUnion<T_2>;
297
293
  any: () => pqb.JSONAny;
298
294
  bigint: () => pqb.JSONBigInt;
@@ -330,12 +326,8 @@ declare const createBaseTable: <CT extends ColumnTypesBase>(options?: {
330
326
  timestamps: <T_14 extends pqb.ColumnType<unknown, pqb.BaseOperators, unknown>>(this: {
331
327
  timestamp(): T_14;
332
328
  }) => {
333
- createdAt: T_14 & {
334
- hasDefault: true;
335
- };
336
- updatedAt: T_14 & {
337
- hasDefault: true;
338
- };
329
+ createdAt: pqb.ColumnWithDefault<T_14, pqb.RawExpression<pqb.ColumnTypeBase<unknown, pqb.BaseOperators, unknown, pqb.ColumnDataBase>>>;
330
+ updatedAt: pqb.ColumnWithDefault<T_14, pqb.RawExpression<pqb.ColumnTypeBase<unknown, pqb.BaseOperators, unknown, pqb.ColumnDataBase>>>;
339
331
  };
340
332
  primaryKey(columns: string[], options?: {
341
333
  name?: string | undefined;
package/dist/index.js CHANGED
@@ -329,8 +329,8 @@ const hasRelationHandleUpdate = (q, ctx, set, key, primaryKey, nestedUpdate) =>
329
329
  };
330
330
 
331
331
  var __defProp$6 = Object.defineProperty;
332
- var __defProps$4 = Object.defineProperties;
333
- var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
332
+ var __defProps$5 = Object.defineProperties;
333
+ var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
334
334
  var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
335
335
  var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
336
336
  var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
@@ -346,7 +346,7 @@ var __spreadValues$6 = (a, b) => {
346
346
  }
347
347
  return a;
348
348
  };
349
- var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
349
+ var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
350
350
  class HasOneVirtualColumn extends pqb.VirtualColumn {
351
351
  constructor(key, state) {
352
352
  super();
@@ -500,7 +500,7 @@ const nestedUpdate$2 = ({ query, primaryKey, foreignKey }) => {
500
500
  if (params.create || params.disconnect || params.set) {
501
501
  await currentRelationsQuery._update({ [foreignKey]: null });
502
502
  if (params.create) {
503
- await t._count()._create(__spreadProps$4(__spreadValues$6({}, params.create), {
503
+ await t._count()._create(__spreadProps$5(__spreadValues$6({}, params.create), {
504
504
  [foreignKey]: data[0][primaryKey]
505
505
  }));
506
506
  }
@@ -516,7 +516,7 @@ const nestedUpdate$2 = ({ query, primaryKey, foreignKey }) => {
516
516
  const updatedIds = await currentRelationsQuery._pluck(foreignKey)._update(update);
517
517
  if (updatedIds.length < ids.length) {
518
518
  await t.createMany(
519
- ids.filter((id) => !updatedIds.includes(id)).map((id) => __spreadProps$4(__spreadValues$6({}, create), {
519
+ ids.filter((id) => !updatedIds.includes(id)).map((id) => __spreadProps$5(__spreadValues$6({}, create), {
520
520
  [foreignKey]: id
521
521
  }))
522
522
  );
@@ -526,8 +526,8 @@ const nestedUpdate$2 = ({ query, primaryKey, foreignKey }) => {
526
526
  };
527
527
 
528
528
  var __defProp$5 = Object.defineProperty;
529
- var __defProps$3 = Object.defineProperties;
530
- var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
529
+ var __defProps$4 = Object.defineProperties;
530
+ var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
531
531
  var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
532
532
  var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
533
533
  var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
@@ -543,7 +543,7 @@ var __spreadValues$5 = (a, b) => {
543
543
  }
544
544
  return a;
545
545
  };
546
- var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
546
+ var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
547
547
  class HasManyVirtualColumn extends pqb.VirtualColumn {
548
548
  constructor(key, state) {
549
549
  super();
@@ -731,7 +731,7 @@ const nestedUpdate$1 = ({ query, primaryKey, foreignKey }) => {
731
731
  const t = query.transacting(q);
732
732
  if (params.create) {
733
733
  await t._count()._createMany(
734
- params.create.map((create) => __spreadProps$3(__spreadValues$5({}, create), {
734
+ params.create.map((create) => __spreadProps$4(__spreadValues$5({}, create), {
735
735
  [foreignKey]: data[0][primaryKey]
736
736
  }))
737
737
  );
@@ -775,6 +775,8 @@ const nestedUpdate$1 = ({ query, primaryKey, foreignKey }) => {
775
775
  };
776
776
 
777
777
  var __defProp$4 = Object.defineProperty;
778
+ var __defProps$3 = Object.defineProperties;
779
+ var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
778
780
  var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
779
781
  var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
780
782
  var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
@@ -790,6 +792,7 @@ var __spreadValues$4 = (a, b) => {
790
792
  }
791
793
  return a;
792
794
  };
795
+ var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
793
796
  class HasAndBelongsToManyVirtualColumn extends pqb.VirtualColumn {
794
797
  constructor(key, state) {
795
798
  super();
@@ -838,8 +841,10 @@ const makeHasAndBelongsToManyMethod = (table, qb, relation, relationName, query)
838
841
  [fk]: table.shape[pk],
839
842
  [afk]: query.shape[apk]
840
843
  };
844
+ baseQuery.query = __spreadProps$3(__spreadValues$4({}, baseQuery.query), {
845
+ shape: baseQuery.shape
846
+ });
841
847
  const subQuery = Object.create(baseQuery);
842
- subQuery.query = __spreadValues$4({}, subQuery.query);
843
848
  const state = {
844
849
  relatedTableQuery: query,
845
850
  joinTableQuery: subQuery,
@@ -1207,7 +1212,7 @@ const applyRelation = (qb, { relationName, relation, dbTable, otherDbTable }, de
1207
1212
  query._take();
1208
1213
  }
1209
1214
  if (data.virtualColumn) {
1210
- dbTable.shape[relationName] = data.virtualColumn;
1215
+ dbTable.shape[relationName] = dbTable.query.shape[relationName] = data.virtualColumn;
1211
1216
  }
1212
1217
  makeRelationQuery(dbTable, definedAs, relationName, data);
1213
1218
  dbTable.relations[relationName] = {