orchid-orm 1.23.10 → 1.24.0
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 +1 -0
- package/dist/index.js +31 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +27 -16
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { makeColumnTypes, defaultSchemaConfig, QueryHooks, getColumnTypes, _queryHookAfterCreate, _queryHookAfterUpdate, getQueryAs, setQueryObjectValue, pushQueryOn, VirtualColumn, pushQueryValue, _queryCreateMany, isQueryReturnsAll, _queryHookBeforeUpdate, _queryFindBy, _queryCreate, _queryRows, _queryUpdate, _queryDelete, _queryDefaults, _queryUpdateOrThrow, _queryWhere, toSQLCacheKey, _queryJoinOn, OrchidOrmInternalError, _queryCreateFrom, NotFoundError, _queryFindByOptional, _querySelect, _queryTake, _queryTakeOptional, _queryAll, Adapter, Db, anyShape, addComputedColumns, getClonedQueryData } from 'pqb';
|
|
2
2
|
export * from 'pqb';
|
|
3
|
-
import { getStackTrace, applyMixins, getCallerFilePath, snakeCaseKey, toSnakeCase, emptyArray, toArray } from 'orchid-core';
|
|
3
|
+
import { getStackTrace, applyMixins, getCallerFilePath, snakeCaseKey, toSnakeCase, emptyArray, objectHasValues, toArray } from 'orchid-core';
|
|
4
|
+
export * from 'orchid-core';
|
|
4
5
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
5
6
|
|
|
6
7
|
function createBaseTable({
|
|
@@ -1034,7 +1035,7 @@ const nestedUpdate$1 = ({ query, primaryKeys, foreignKeys }) => {
|
|
|
1034
1035
|
),
|
|
1035
1036
|
obj
|
|
1036
1037
|
);
|
|
1037
|
-
if (params.set) {
|
|
1038
|
+
if (params.set && (Array.isArray(params.set) ? params.set.length : objectHasValues(params.set))) {
|
|
1038
1039
|
delete t.q[toSQLCacheKey];
|
|
1039
1040
|
const obj2 = {};
|
|
1040
1041
|
for (let i = 0; i < len; i++) {
|
|
@@ -1143,10 +1144,17 @@ const makeHasAndBelongsToManyMethod = (table, qb, relation, relationName, query)
|
|
|
1143
1144
|
throughForeignKeys = [options.associationForeignKey];
|
|
1144
1145
|
throughPrimaryKeys = [options.associationPrimaryKey];
|
|
1145
1146
|
}
|
|
1146
|
-
const
|
|
1147
|
-
const
|
|
1148
|
-
(
|
|
1149
|
-
|
|
1147
|
+
const { snakeCase } = table.internal;
|
|
1148
|
+
const foreignKeysFull = foreignKeys.map((key, i) => {
|
|
1149
|
+
if (snakeCase)
|
|
1150
|
+
key = foreignKeys[i] = toSnakeCase(key);
|
|
1151
|
+
return `${joinTable}.${key}`;
|
|
1152
|
+
});
|
|
1153
|
+
const throughForeignKeysFull = throughForeignKeys.map((key, i) => {
|
|
1154
|
+
if (snakeCase)
|
|
1155
|
+
key = throughForeignKeys[i] = toSnakeCase(key);
|
|
1156
|
+
return `${joinTable}.${key}`;
|
|
1157
|
+
});
|
|
1150
1158
|
const foreignTable = getQueryAs(query);
|
|
1151
1159
|
const throughPrimaryKeysFull = throughPrimaryKeys.map(
|
|
1152
1160
|
(key) => `${foreignTable}.${key}`
|
|
@@ -1532,15 +1540,17 @@ const nestedUpdate = (state) => {
|
|
|
1532
1540
|
const j = queryJoinTable(state, data);
|
|
1533
1541
|
await _queryDelete(j);
|
|
1534
1542
|
delete j.q[toSQLCacheKey];
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1543
|
+
if (Array.isArray(params.set) ? params.set.length : objectHasValues(params.set)) {
|
|
1544
|
+
const idsRows = await _queryRows(
|
|
1545
|
+
_querySelect(
|
|
1546
|
+
state.relatedTableQuery.where(
|
|
1547
|
+
conditionsToWhereArg(params.set)
|
|
1548
|
+
),
|
|
1549
|
+
state.throughPrimaryKeys
|
|
1550
|
+
)
|
|
1551
|
+
);
|
|
1552
|
+
await insertToJoinTable(state, j, data, idsRows);
|
|
1553
|
+
}
|
|
1544
1554
|
}
|
|
1545
1555
|
};
|
|
1546
1556
|
};
|
|
@@ -1857,7 +1867,8 @@ const orchidORM = (_a, tables) => {
|
|
|
1857
1867
|
schema: table.schema,
|
|
1858
1868
|
language: table.language,
|
|
1859
1869
|
scopes: table.scopes,
|
|
1860
|
-
softDelete: table.softDelete
|
|
1870
|
+
softDelete: table.softDelete,
|
|
1871
|
+
snakeCase: table.snakeCase
|
|
1861
1872
|
});
|
|
1862
1873
|
if (table.noPrimaryKey)
|
|
1863
1874
|
options2.noPrimaryKey = "ignore";
|