orchid-orm 1.6.33 → 1.6.35
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/bin.js +4 -4
- package/dist/bin.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +13 -39
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -39
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { columnTypes, getColumnTypes, addQueryOn, VirtualColumn, pushQueryValue, isQueryReturnsAll, getQueryAs, toSqlCacheKey, NotFoundError, relationQueryKey, Db, Adapter, anyShape, getClonedQueryData, columnsShapeToCode, primaryKeyToCode, indexToCode, constraintToCode, columnIndexesToCode, columnForeignKeysToCode, columnCheckToCode } from 'pqb';
|
|
1
|
+
import { columnTypes, getColumnTypes, addQueryOn, VirtualColumn, pushQueryValue, isQueryReturnsAll, getQueryAs, toSqlCacheKey, NotFoundError, relationQueryKey, Db, Adapter, anyShape, getClonedQueryData, columnsShapeToCode, primaryKeyToCode, indexToCode, constraintToCode, columnIndexesToCode, columnForeignKeysToCode, columnCheckToCode, identityToCode } from 'pqb';
|
|
2
2
|
export { OrchidOrmError, OrchidOrmInternalError, columnTypes } from 'pqb';
|
|
3
|
-
import { snakeCaseKey, toSnakeCase, emptyObject, pathToLog, toCamelCase, toPascalCase, singleQuote, codeToString, quoteObjectKey, addCode, columnDefaultArgumentToCode } from 'orchid-core';
|
|
3
|
+
import { snakeCaseKey, toSnakeCase, emptyObject, pathToLog, toCamelCase, toPascalCase, singleQuote, codeToString, quoteObjectKey, addCode, columnDefaultArgumentToCode, deepCompare } from 'orchid-core';
|
|
4
4
|
import * as path from 'path';
|
|
5
5
|
import path__default from 'path';
|
|
6
6
|
import fs from 'fs/promises';
|
|
@@ -1999,7 +1999,7 @@ const removeProp = ({ props, changes }, prop, i) => {
|
|
|
1999
1999
|
};
|
|
2000
2000
|
const changeColumn = ({ changes, t, spaces }, changeItem, prop) => {
|
|
2001
2001
|
const { from, to } = changeItem;
|
|
2002
|
-
if (from.type !== to.type && to.column) {
|
|
2002
|
+
if ((from.type !== to.type || !!from.identity !== !!to.identity) && to.column) {
|
|
2003
2003
|
changes.replace(
|
|
2004
2004
|
prop.initializer.pos,
|
|
2005
2005
|
prop.end,
|
|
@@ -2039,7 +2039,10 @@ const changeColumn = ({ changes, t, spaces }, changeItem, prop) => {
|
|
|
2039
2039
|
continue;
|
|
2040
2040
|
let remove = true;
|
|
2041
2041
|
if (!replaced[key]) {
|
|
2042
|
-
|
|
2042
|
+
let code = getColumnMethodArgs(t, to, key, to.type);
|
|
2043
|
+
if (!code && key === "identity" && to.type) {
|
|
2044
|
+
code = [`.${to.type}()`];
|
|
2045
|
+
}
|
|
2043
2046
|
if (code) {
|
|
2044
2047
|
changes.replace(
|
|
2045
2048
|
item.expression.expression.end,
|
|
@@ -2116,7 +2119,7 @@ ${spaces}`);
|
|
|
2116
2119
|
}
|
|
2117
2120
|
}
|
|
2118
2121
|
};
|
|
2119
|
-
const getColumnMethodArgs = (t, to, key) => {
|
|
2122
|
+
const getColumnMethodArgs = (t, to, key, dataType) => {
|
|
2120
2123
|
const value = to[key];
|
|
2121
2124
|
if (!value)
|
|
2122
2125
|
return;
|
|
@@ -2129,6 +2132,11 @@ const getColumnMethodArgs = (t, to, key) => {
|
|
|
2129
2132
|
if (key === "check") {
|
|
2130
2133
|
return [columnCheckToCode(t, value)];
|
|
2131
2134
|
}
|
|
2135
|
+
if (key === "identity") {
|
|
2136
|
+
const code2 = identityToCode(value, dataType);
|
|
2137
|
+
code2[0] = `.${code2[0]}`;
|
|
2138
|
+
return code2;
|
|
2139
|
+
}
|
|
2132
2140
|
const code = [`.${key}(`];
|
|
2133
2141
|
if (key === "collate" || key === "compression") {
|
|
2134
2142
|
addCode(code, singleQuote(value));
|
|
@@ -2298,40 +2306,6 @@ const collectObjectFromCode = (node) => {
|
|
|
2298
2306
|
}
|
|
2299
2307
|
return object;
|
|
2300
2308
|
};
|
|
2301
|
-
const deepCompare = (a, b) => {
|
|
2302
|
-
if (typeof a !== typeof b) {
|
|
2303
|
-
if (a === void 0 && typeof b === "object") {
|
|
2304
|
-
a = emptyObject;
|
|
2305
|
-
} else if (typeof a === "object" && b === void 0) {
|
|
2306
|
-
b = emptyObject;
|
|
2307
|
-
} else {
|
|
2308
|
-
return false;
|
|
2309
|
-
}
|
|
2310
|
-
}
|
|
2311
|
-
if (a === b)
|
|
2312
|
-
return true;
|
|
2313
|
-
if (typeof a === "object") {
|
|
2314
|
-
if (a === null)
|
|
2315
|
-
return b === null;
|
|
2316
|
-
if (Array.isArray(a)) {
|
|
2317
|
-
if (!Array.isArray(b) || a.length !== b.length)
|
|
2318
|
-
return false;
|
|
2319
|
-
return a.every((item, i) => deepCompare(item, b[i]));
|
|
2320
|
-
}
|
|
2321
|
-
for (const key in a) {
|
|
2322
|
-
if (!deepCompare(
|
|
2323
|
-
a[key],
|
|
2324
|
-
b[key]
|
|
2325
|
-
))
|
|
2326
|
-
return false;
|
|
2327
|
-
}
|
|
2328
|
-
for (const key in b) {
|
|
2329
|
-
if (!(key in a))
|
|
2330
|
-
return false;
|
|
2331
|
-
}
|
|
2332
|
-
}
|
|
2333
|
-
return true;
|
|
2334
|
-
};
|
|
2335
2309
|
|
|
2336
2310
|
var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
|
|
2337
2311
|
var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
|