orchid-orm 1.5.29 → 1.5.30
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.js +10 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +13 -22
- package/.env.example +0 -1
- package/.turbo/turbo-check.log +0 -26
- package/.turbo/turbo-test.log +0 -26
- package/.turbo/turbo-test:ci.log +0 -26
- package/CHANGELOG.md +0 -382
- package/coverage/coverage-summary.json +0 -28
- package/jest-setup.ts +0 -11
- package/rollup.config.js +0 -18
- package/src/bin/bin.ts +0 -3
- package/src/bin/init.test.ts +0 -810
- package/src/bin/init.ts +0 -529
- package/src/codegen/appCodeUpdater.test.ts +0 -75
- package/src/codegen/appCodeUpdater.ts +0 -53
- package/src/codegen/createBaseTableFile.test.ts +0 -53
- package/src/codegen/createBaseTableFile.ts +0 -31
- package/src/codegen/fileChanges.ts +0 -41
- package/src/codegen/testUtils.ts +0 -56
- package/src/codegen/tsUtils.ts +0 -180
- package/src/codegen/updateMainFile.test.ts +0 -253
- package/src/codegen/updateMainFile.ts +0 -210
- package/src/codegen/updateTableFile/changeTable.test.ts +0 -804
- package/src/codegen/updateTableFile/changeTable.ts +0 -536
- package/src/codegen/updateTableFile/createTable.test.ts +0 -139
- package/src/codegen/updateTableFile/createTable.ts +0 -51
- package/src/codegen/updateTableFile/renameTable.test.ts +0 -124
- package/src/codegen/updateTableFile/renameTable.ts +0 -67
- package/src/codegen/updateTableFile/updateTableFile.ts +0 -22
- package/src/codegen/utils.ts +0 -13
- package/src/index.ts +0 -5
- package/src/orm.test.ts +0 -92
- package/src/orm.ts +0 -98
- package/src/relations/belongsTo.test.ts +0 -1122
- package/src/relations/belongsTo.ts +0 -352
- package/src/relations/hasAndBelongsToMany.test.ts +0 -1335
- package/src/relations/hasAndBelongsToMany.ts +0 -472
- package/src/relations/hasMany.test.ts +0 -2616
- package/src/relations/hasMany.ts +0 -401
- package/src/relations/hasOne.test.ts +0 -1701
- package/src/relations/hasOne.ts +0 -351
- package/src/relations/relations.test.ts +0 -37
- package/src/relations/relations.ts +0 -363
- package/src/relations/utils.ts +0 -162
- package/src/repo.test.ts +0 -200
- package/src/repo.ts +0 -119
- package/src/table.test.ts +0 -121
- package/src/table.ts +0 -184
- package/src/test-utils/test-db.ts +0 -32
- package/src/test-utils/test-tables.ts +0 -194
- package/src/test-utils/test-utils.ts +0 -119
- package/src/transaction.test.ts +0 -47
- package/src/transaction.ts +0 -27
- package/src/utils.ts +0 -9
- package/tsconfig.json +0 -14
package/dist/index.js
CHANGED
|
@@ -831,14 +831,14 @@ const makeHasAndBelongsToManyMethod = (table, qb, relation, relationName, query)
|
|
|
831
831
|
const foreignKeyFull = `${joinTable}.${fk}`;
|
|
832
832
|
const associationForeignKeyFull = `${joinTable}.${afk}`;
|
|
833
833
|
const associationPrimaryKeyFull = `${pqb.getQueryAs(query)}.${apk}`;
|
|
834
|
-
const
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
834
|
+
const baseQuery = Object.create(qb.baseQuery);
|
|
835
|
+
baseQuery.baseQuery = baseQuery;
|
|
836
|
+
baseQuery.table = joinTable;
|
|
837
|
+
baseQuery.shape = {
|
|
838
838
|
[fk]: table.shape[pk],
|
|
839
839
|
[afk]: query.shape[apk]
|
|
840
840
|
};
|
|
841
|
-
const subQuery = Object.create(
|
|
841
|
+
const subQuery = Object.create(baseQuery);
|
|
842
842
|
subQuery.query = __spreadValues$4({}, subQuery.query);
|
|
843
843
|
const state = {
|
|
844
844
|
relatedTableQuery: query,
|
|
@@ -1262,7 +1262,7 @@ function transaction(fn) {
|
|
|
1262
1262
|
const value = this[key];
|
|
1263
1263
|
if (value instanceof pqb.Db) {
|
|
1264
1264
|
const table = value.transacting(q);
|
|
1265
|
-
table.
|
|
1265
|
+
table.baseQuery = table;
|
|
1266
1266
|
table.db = orm;
|
|
1267
1267
|
orm[key] = table;
|
|
1268
1268
|
} else {
|
|
@@ -1386,16 +1386,16 @@ const createRepo = (table, methods) => {
|
|
|
1386
1386
|
const queryMethods = __spreadValues$2(__spreadValues$2(__spreadValues$2(__spreadValues$2({}, methods.queryMethods), methods.queryOneMethods), methods.queryWithWhereMethods), methods.queryOneWithWhereMethods);
|
|
1387
1387
|
const plainMethods = methods.methods;
|
|
1388
1388
|
const repo = (q2) => {
|
|
1389
|
-
const proto = Object.create(q2.
|
|
1390
|
-
proto.
|
|
1389
|
+
const proto = Object.create(q2.baseQuery);
|
|
1390
|
+
proto.baseQuery = proto;
|
|
1391
1391
|
const result = Object.create(proto);
|
|
1392
1392
|
result.query = pqb.getClonedQueryData(q2.query);
|
|
1393
1393
|
if (plainMethods) {
|
|
1394
|
-
Object.assign(proto.
|
|
1394
|
+
Object.assign(proto.baseQuery, plainMethods);
|
|
1395
1395
|
}
|
|
1396
1396
|
for (const key in queryMethods) {
|
|
1397
1397
|
const method = queryMethods[key];
|
|
1398
|
-
proto.
|
|
1398
|
+
proto.baseQuery[key] = function(...args) {
|
|
1399
1399
|
return method(this, ...args);
|
|
1400
1400
|
};
|
|
1401
1401
|
}
|