orchid-orm 1.9.20 → 1.9.22
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 +6 -4
- package/dist/index.js +21 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +21 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -11,7 +11,8 @@ import { pluralize } from 'inflection';
|
|
|
11
11
|
const createBaseTable = ({
|
|
12
12
|
columnTypes: columnTypes$1,
|
|
13
13
|
snakeCase,
|
|
14
|
-
filePath
|
|
14
|
+
filePath,
|
|
15
|
+
nowSQL
|
|
15
16
|
} = { columnTypes: columnTypes }) => {
|
|
16
17
|
const ct = typeof columnTypes$1 === "function" ? columnTypes$1(columnTypes) : columnTypes$1 || columnTypes;
|
|
17
18
|
filePath != null ? filePath : filePath = getCallerFilePath();
|
|
@@ -23,10 +24,11 @@ const createBaseTable = ({
|
|
|
23
24
|
return create(
|
|
24
25
|
ct,
|
|
25
26
|
filePath,
|
|
26
|
-
snakeCase
|
|
27
|
+
snakeCase,
|
|
28
|
+
nowSQL
|
|
27
29
|
);
|
|
28
30
|
};
|
|
29
|
-
const create = (columnTypes, filePath, snakeCase) => {
|
|
31
|
+
const create = (columnTypes, filePath, snakeCase, nowSQL) => {
|
|
30
32
|
var _a;
|
|
31
33
|
const base = (_a = class {
|
|
32
34
|
constructor() {
|
|
@@ -44,7 +46,7 @@ const create = (columnTypes, filePath, snakeCase) => {
|
|
|
44
46
|
this.filePath = filePath2;
|
|
45
47
|
}
|
|
46
48
|
columnTypes[snakeCaseKey] = this.snakeCase;
|
|
47
|
-
const shape = getColumnTypes(columnTypes, fn);
|
|
49
|
+
const shape = getColumnTypes(columnTypes, fn, nowSQL);
|
|
48
50
|
if (this.snakeCase) {
|
|
49
51
|
for (const key in shape) {
|
|
50
52
|
const column = shape[key];
|
|
@@ -93,7 +95,7 @@ const create = (columnTypes, filePath, snakeCase) => {
|
|
|
93
95
|
options
|
|
94
96
|
};
|
|
95
97
|
}
|
|
96
|
-
}, _a.filePath = filePath, _a);
|
|
98
|
+
}, _a.filePath = filePath, _a.nowSQL = nowSQL, _a);
|
|
97
99
|
base.prototype.columnTypes = columnTypes;
|
|
98
100
|
return base;
|
|
99
101
|
};
|
|
@@ -256,7 +258,8 @@ const nestedUpdate$3 = ({ query, primaryKey, foreignKey }) => {
|
|
|
256
258
|
if (id !== null) {
|
|
257
259
|
await query.findBy({ [primaryKey]: id })._update(upsert.update);
|
|
258
260
|
} else {
|
|
259
|
-
const
|
|
261
|
+
const data = typeof upsert.create === "function" ? upsert.create() : upsert.create;
|
|
262
|
+
const result = await query.select(primaryKey)._create(data);
|
|
260
263
|
((_a2 = state.updateData) != null ? _a2 : state.updateData = {})[foreignKey] = result[primaryKey];
|
|
261
264
|
}
|
|
262
265
|
});
|
|
@@ -521,8 +524,9 @@ const nestedUpdate$2 = ({ query, primaryKey, foreignKey }) => {
|
|
|
521
524
|
const { update, create } = params.upsert;
|
|
522
525
|
const updatedIds = await currentRelationsQuery._pluck(foreignKey)._update(update);
|
|
523
526
|
if (updatedIds.length < ids.length) {
|
|
527
|
+
const data2 = typeof create === "function" ? create() : create;
|
|
524
528
|
await t.createMany(
|
|
525
|
-
ids.filter((id) => !updatedIds.includes(id)).map((id) => __spreadProps$5(__spreadValues$7({},
|
|
529
|
+
ids.filter((id) => !updatedIds.includes(id)).map((id) => __spreadProps$5(__spreadValues$7({}, data2), {
|
|
526
530
|
[foreignKey]: id
|
|
527
531
|
}))
|
|
528
532
|
);
|
|
@@ -1243,6 +1247,16 @@ const applyRelation = (qb, { relationName, relation, dbTable, otherDbTable }, de
|
|
|
1243
1247
|
}
|
|
1244
1248
|
makeRelationQuery(dbTable, relationName, data, query);
|
|
1245
1249
|
baseQuery.joinQuery = data.joinQuery;
|
|
1250
|
+
const { join: originalJoin } = baseQuery;
|
|
1251
|
+
baseQuery.join = function(...args) {
|
|
1252
|
+
if (args.length) {
|
|
1253
|
+
return originalJoin.apply(this, args);
|
|
1254
|
+
} else {
|
|
1255
|
+
const q = this.clone();
|
|
1256
|
+
q.query.innerJoinLateral = true;
|
|
1257
|
+
return q;
|
|
1258
|
+
}
|
|
1259
|
+
};
|
|
1246
1260
|
dbTable.relations[relationName] = {
|
|
1247
1261
|
type,
|
|
1248
1262
|
key: relationName,
|