orchid-orm 1.55.1 → 1.56.2

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
@@ -1,4 +1,4 @@
1
- import { makeColumnTypes, QueryHooks, defaultSchemaConfig, raw, getColumnTypes, parseTableData, _queryHookAfterCreate, _queryHookAfterUpdate, getQueryAs, setQueryObjectValueImmutable, pushQueryOnForOuter, cloneQueryBaseUnscoped, DynamicRawSQL, RawSQL, getShapeFromSelect, _queryWhere, _queryDefaults, VirtualColumn, _queryCreateMany, isQueryReturnsAll, _queryHookBeforeUpdate, _queryFindBy, _queryCreate, _queryRows, _queryUpdate, _queryDelete, _queryUpdateOrThrow, _queryJoinOn, _queryCreateFrom, _queryFindByOptional, _querySelect, _queryWhereExists, _queryTake, _queryTakeOptional, Adapter, _initQueryBuilder, Db, getClonedQueryData } from 'pqb';
1
+ import { makeColumnTypes, QueryHooks, defaultSchemaConfig, raw, getColumnTypes, parseTableData, _queryHookAfterCreate, _queryHookAfterUpdate, getQueryAs, setQueryObjectValueImmutable, pushQueryOnForOuter, cloneQueryBaseUnscoped, DynamicRawSQL, RawSQL, getShapeFromSelect, _queryWhere, _queryDefaults, VirtualColumn, _queryCreateMany, isQueryReturnsAll, _queryHookBeforeUpdate, _queryFindBy, _queryCreate, _queryRows, _queryUpdate, _queryDelete, _queryUpdateOrThrow, _queryJoinOn, _queryCreateFrom, _queryFindByOptional, _querySelect, _queryWhereExists, _queryTake, _queryTakeOptional, _initQueryBuilder, Db, getClonedQueryData } from 'pqb';
2
2
  export * from 'pqb';
3
3
  import { getStackTrace, applyMixins, getCallerFilePath, snakeCaseKey, toSnakeCase, emptyObject, emptyArray, isExpression, getPrimaryKeys, pushQueryValueImmutable, OrchidOrmInternalError, toArray, objectHasValues, NotFoundError, pick } from 'orchid-core';
4
4
  export * from 'orchid-core';
@@ -615,9 +615,10 @@ const nestedUpdate$3 = ({ query, primaryKeys, foreignKeys, len }) => {
615
615
  }
616
616
  }
617
617
  if (loadPrimaryKeys) {
618
- const record = await _queryFindBy(query.select(...loadPrimaryKeys), [
618
+ const record = await _queryFindBy(
619
+ query.select(...loadPrimaryKeys),
619
620
  params.set
620
- ]);
621
+ );
621
622
  for (let i = 0, len2 = loadPrimaryKeys.length; i < len2; i++) {
622
623
  update[loadForeignKeys[i]] = record[loadPrimaryKeys[i]];
623
624
  }
@@ -644,7 +645,9 @@ const nestedUpdate$3 = ({ query, primaryKeys, foreignKeys, len }) => {
644
645
  }
645
646
  });
646
647
  const { upsert } = params;
647
- if (upsert || params.update || params.delete) ;
648
+ if (upsert || params.update || params.delete) {
649
+ selectIfNotSelected(q, foreignKeys);
650
+ }
648
651
  if (upsert) {
649
652
  (state.queries ?? (state.queries = [])).push(async (queryResult) => {
650
653
  const row = queryResult.rows[0];
@@ -1635,9 +1638,10 @@ const nestedInsert = ({
1635
1638
  for (const [, { connect }] of items) {
1636
1639
  for (const item of connect) {
1637
1640
  queries.push(
1638
- _queryFindBy(t.select(...throughPrimaryKeys), [
1641
+ _queryFindBy(
1642
+ t.select(...throughPrimaryKeys),
1639
1643
  item
1640
- ])
1644
+ )
1641
1645
  );
1642
1646
  }
1643
1647
  }
@@ -1657,9 +1661,10 @@ const nestedInsert = ({
1657
1661
  for (const [, { connectOrCreate }] of items) {
1658
1662
  for (const item of connectOrCreate) {
1659
1663
  queries.push(
1660
- _queryFindByOptional(t.select(...throughPrimaryKeys), [
1664
+ _queryFindByOptional(
1665
+ t.select(...throughPrimaryKeys),
1661
1666
  item.where
1662
- ])
1667
+ )
1663
1668
  );
1664
1669
  }
1665
1670
  }
@@ -2065,7 +2070,7 @@ function afterCommit(hook) {
2065
2070
  this.$qb.afterCommit(hook);
2066
2071
  }
2067
2072
 
2068
- const orchidORM = ({
2073
+ const orchidORMWithAdapter = ({
2069
2074
  log,
2070
2075
  logger,
2071
2076
  autoPreparedStatements,
@@ -2086,7 +2091,7 @@ const orchidORM = ({
2086
2091
  transactionStorage = options.db.internal.transactionStorage;
2087
2092
  qb = options.db.qb;
2088
2093
  } else {
2089
- adapter = "adapter" in options ? options.adapter : new Adapter(options);
2094
+ adapter = options.adapter;
2090
2095
  transactionStorage = new AsyncLocalStorage();
2091
2096
  qb = _initQueryBuilder(
2092
2097
  adapter,
@@ -2195,5 +2200,5 @@ const createRepo = (table, methods) => {
2195
2200
  });
2196
2201
  };
2197
2202
 
2198
- export { createBaseTable, createRepo, orchidORM };
2203
+ export { createBaseTable, createRepo, orchidORMWithAdapter };
2199
2204
  //# sourceMappingURL=index.mjs.map