orchid-orm 1.6.14 → 1.6.16
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 +11 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -450,7 +450,7 @@ const makeHasOneMethod = (table, relation, relationName, query) => {
|
|
|
450
450
|
return (query2) => {
|
|
451
451
|
const fromQuery = query2.clone();
|
|
452
452
|
fromQuery.query.select = fromQuerySelect;
|
|
453
|
-
relationQuery.query.
|
|
453
|
+
relationQuery.query.values = { from: fromQuery };
|
|
454
454
|
};
|
|
455
455
|
}
|
|
456
456
|
};
|
|
@@ -646,7 +646,7 @@ const makeHasManyMethod = (table, relation, relationName, query) => {
|
|
|
646
646
|
return (query2) => {
|
|
647
647
|
const fromQuery = query2.clone();
|
|
648
648
|
fromQuery.query.select = fromQuerySelect;
|
|
649
|
-
relationQuery.query.
|
|
649
|
+
relationQuery.query.values = { from: fromQuery };
|
|
650
650
|
};
|
|
651
651
|
}
|
|
652
652
|
};
|
|
@@ -1823,7 +1823,7 @@ const createTable = async (_a) => {
|
|
|
1823
1823
|
];
|
|
1824
1824
|
await fs__default["default"].mkdir(path__default["default"].dirname(tablePath), { recursive: true });
|
|
1825
1825
|
try {
|
|
1826
|
-
await fs__default["default"].writeFile(tablePath,
|
|
1826
|
+
await fs__default["default"].writeFile(tablePath, orchidCore.codeToString(code, "", " "), { flag: "wx" });
|
|
1827
1827
|
logger == null ? void 0 : logger.log(`Created ${orchidCore.pathToLog(tablePath)}`);
|
|
1828
1828
|
} catch (err) {
|
|
1829
1829
|
if (err.code !== "EEXIST") {
|
|
@@ -2006,7 +2006,7 @@ const changeColumn = ({ changes, t, spaces }, changeItem, prop) => {
|
|
|
2006
2006
|
changes.replace(
|
|
2007
2007
|
prop.initializer.pos,
|
|
2008
2008
|
prop.end,
|
|
2009
|
-
` ${
|
|
2009
|
+
` ${orchidCore.codeToString(to.column.toCode(t), spaces + " ", " ").trim()}`
|
|
2010
2010
|
);
|
|
2011
2011
|
return;
|
|
2012
2012
|
}
|
|
@@ -2047,7 +2047,7 @@ const changeColumn = ({ changes, t, spaces }, changeItem, prop) => {
|
|
|
2047
2047
|
changes.replace(
|
|
2048
2048
|
item.expression.expression.end,
|
|
2049
2049
|
item.end,
|
|
2050
|
-
|
|
2050
|
+
orchidCore.codeToString(code, spaces + " ", " ").trim()
|
|
2051
2051
|
);
|
|
2052
2052
|
replaced[key] = true;
|
|
2053
2053
|
remove = false;
|
|
@@ -2064,7 +2064,7 @@ const changeColumn = ({ changes, t, spaces }, changeItem, prop) => {
|
|
|
2064
2064
|
continue;
|
|
2065
2065
|
const code = getColumnMethodArgs(t, to, key);
|
|
2066
2066
|
if (code) {
|
|
2067
|
-
append +=
|
|
2067
|
+
append += orchidCore.codeToString(code, spaces + " ", " ").trim();
|
|
2068
2068
|
}
|
|
2069
2069
|
}
|
|
2070
2070
|
if (append) {
|
|
@@ -2088,7 +2088,7 @@ const addColumns = ({
|
|
|
2088
2088
|
}) => {
|
|
2089
2089
|
const end = object.end - 1;
|
|
2090
2090
|
for (const key in add) {
|
|
2091
|
-
const code =
|
|
2091
|
+
const code = orchidCore.codeToString(add[key].toCode(t), spaces + " ", " ");
|
|
2092
2092
|
changes.add(end, ` ${orchidCore.quoteObjectKey(key)}: ${code.trim()},
|
|
2093
2093
|
${spaces}`);
|
|
2094
2094
|
}
|
|
@@ -2096,7 +2096,7 @@ ${spaces}`);
|
|
|
2096
2096
|
const addTableData = ({ add, changes, object, t, spaces }) => {
|
|
2097
2097
|
const end = object.end - 1;
|
|
2098
2098
|
if (add.primaryKey) {
|
|
2099
|
-
const code =
|
|
2099
|
+
const code = orchidCore.codeToString(
|
|
2100
2100
|
pqb.primaryKeyToCode(add.primaryKey, t),
|
|
2101
2101
|
spaces,
|
|
2102
2102
|
" "
|
|
@@ -2105,12 +2105,12 @@ const addTableData = ({ add, changes, object, t, spaces }) => {
|
|
|
2105
2105
|
${spaces}`);
|
|
2106
2106
|
}
|
|
2107
2107
|
for (const item of add.indexes) {
|
|
2108
|
-
const code =
|
|
2108
|
+
const code = orchidCore.codeToString(pqb.indexToCode(item, t), spaces + " ", " ");
|
|
2109
2109
|
changes.add(end, ` ${code.trim()}
|
|
2110
2110
|
${spaces}`);
|
|
2111
2111
|
}
|
|
2112
2112
|
for (const item of add.foreignKeys) {
|
|
2113
|
-
const code =
|
|
2113
|
+
const code = orchidCore.codeToString(pqb.foreignKeyToCode(item, t), spaces + " ", " ");
|
|
2114
2114
|
changes.add(end, ` ${code.trim()}
|
|
2115
2115
|
${spaces}`);
|
|
2116
2116
|
}
|
|
@@ -2132,7 +2132,7 @@ const getColumnMethodArgs = (t, to, key) => {
|
|
|
2132
2132
|
if (key === "collate" || key === "compression") {
|
|
2133
2133
|
orchidCore.addCode(code, orchidCore.singleQuote(value));
|
|
2134
2134
|
} else if (key === "default") {
|
|
2135
|
-
orchidCore.addCode(code,
|
|
2135
|
+
orchidCore.addCode(code, orchidCore.columnDefaultArgumentToCode(t, value));
|
|
2136
2136
|
} else if (key !== "nullable" && key !== "primaryKey") {
|
|
2137
2137
|
return;
|
|
2138
2138
|
}
|