pqb 0.5.1 → 0.5.3

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.esm.js CHANGED
@@ -4202,13 +4202,13 @@ const processCreateItem = (item, rowIndex, ctx, columns, encoders, columnsMap, s
4202
4202
  item[key]
4203
4203
  ]);
4204
4204
  } else {
4205
+ const value = item[key];
4206
+ if ((!value.create || Array.isArray(value.create) && value.create.length === 0) && (!value.connect || Array.isArray(value.connect) && value.connect.length === 0) && (!value.connectOrCreate || Array.isArray(value.connectOrCreate) && value.connectOrCreate.length === 0))
4207
+ return;
4205
4208
  ctx.requiredReturning[ctx.relations[key].primaryKey] = true;
4206
4209
  if (!ctx.appendRelations[key])
4207
4210
  ctx.appendRelations[key] = [];
4208
- ctx.appendRelations[key].push([
4209
- rowIndex,
4210
- item[key]
4211
- ]);
4211
+ ctx.appendRelations[key].push([rowIndex, value]);
4212
4212
  }
4213
4213
  } else if (columnsMap[key] === void 0 && (shape[key] || shape === anyShape)) {
4214
4214
  columnsMap[key] = columns.length;
@@ -4293,7 +4293,7 @@ const insert = (self, {
4293
4293
  if (prependRelationsKeys.length) {
4294
4294
  pushQueryArray(
4295
4295
  q,
4296
- "beforeQuery",
4296
+ "beforeCreate",
4297
4297
  prependRelationsKeys.map((relationName) => {
4298
4298
  return async (q2) => {
4299
4299
  const relationData = ctx.prependRelations[relationName];
@@ -4346,7 +4346,7 @@ const insert = (self, {
4346
4346
  }
4347
4347
  pushQueryArray(
4348
4348
  q,
4349
- "afterQuery",
4349
+ "afterCreate",
4350
4350
  appendRelationsKeys.map((relationName) => {
4351
4351
  return (q2, result) => {
4352
4352
  var _a2, _b;
@@ -5151,6 +5151,9 @@ class Update {
5151
5151
  if (relations[key].type === "belongsTo") {
5152
5152
  prependRelations[key] = data[key];
5153
5153
  } else {
5154
+ const value = data[key];
5155
+ if (!value.set && !("upsert" in value) && (!value.disconnect || Array.isArray(value.disconnect) && value.disconnect.length === 0) && (!value.delete || Array.isArray(value.delete) && value.delete.length === 0) && (!value.update || Array.isArray(value.update.where) && value.update.where.length === 0) && (!value.create || Array.isArray(value.create) && value.create.length === 0))
5156
+ continue;
5154
5157
  if (!((_a = query.select) == null ? void 0 : _a.includes("*"))) {
5155
5158
  const primaryKey = relations[key].primaryKey;
5156
5159
  if (!((_b = query.select) == null ? void 0 : _b.includes(primaryKey))) {
@@ -5220,7 +5223,7 @@ class Update {
5220
5223
  if (appendRelationKeys.length) {
5221
5224
  pushQueryArray(
5222
5225
  this,
5223
- "afterQuery",
5226
+ "afterUpdate",
5224
5227
  appendRelationKeys.map((relationName) => {
5225
5228
  return (q, result) => {
5226
5229
  var _a2, _b2;