orchid-orm 1.4.21 → 1.4.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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # orchid-orm
2
2
 
3
+ ## 1.4.22
4
+
5
+ ### Patch Changes
6
+
7
+ - Change inner aspects of columns
8
+ - Updated dependencies
9
+ - pqb@0.8.5
10
+
3
11
  ## 1.4.21
4
12
 
5
13
  ### Patch Changes
package/dist/index.esm.js CHANGED
@@ -1727,7 +1727,11 @@ const createTable = async (_a) => {
1727
1727
  ]);
1728
1728
  const tablePath = params.tablePath(ast.name);
1729
1729
  const baseTablePath = getImportPath(tablePath, params.baseTablePath);
1730
- const props = [`table = ${singleQuote(ast.name)};`];
1730
+ const props = [];
1731
+ if (ast.schema) {
1732
+ props.push(`schema = ${singleQuote(ast.schema)};`);
1733
+ }
1734
+ props.push(`table = ${singleQuote(ast.name)};`);
1731
1735
  if (ast.noPrimaryKey === "ignore") {
1732
1736
  props.push("noPrimaryKey = true;");
1733
1737
  }
@@ -2170,17 +2174,38 @@ const renameTable = async (_a) => {
2170
2174
  const changes = new FileChanges(content);
2171
2175
  const statements = ts.getStatements(content);
2172
2176
  const className = toPascalCase(ast.from);
2177
+ const changeSchema = ast.fromSchema !== ast.toSchema;
2173
2178
  for (const node of ts.class.iterate(statements)) {
2174
2179
  if (((_a2 = node.name) == null ? void 0 : _a2.escapedText) !== className)
2175
2180
  continue;
2181
+ const addSchema = changeSchema && ast.toSchema && !node.members.some((member) => ts.prop.getName(member) === "schema");
2182
+ if (addSchema && ast.toSchema) {
2183
+ changes.add(
2184
+ node.members.pos,
2185
+ `
2186
+ schema = ${singleQuote(ast.toSchema)};`
2187
+ );
2188
+ }
2176
2189
  for (const member of node.members) {
2177
2190
  const name = ts.prop.getName(member);
2178
- if (name !== "table")
2191
+ if (name !== "table" && !(changeSchema && name === "schema"))
2179
2192
  continue;
2180
2193
  const { initializer: value } = member;
2181
2194
  if (!value)
2182
2195
  continue;
2183
- changes.replace(value.pos, value.end, ` ${singleQuote(ast.to)}`);
2196
+ if (name === "schema") {
2197
+ if (ast.toSchema) {
2198
+ changes.replace(
2199
+ value.pos,
2200
+ value.end,
2201
+ ` ${singleQuote(ast.toSchema)}`
2202
+ );
2203
+ } else {
2204
+ changes.remove(member.pos, member.end);
2205
+ }
2206
+ } else {
2207
+ changes.replace(value.pos, value.end, ` ${singleQuote(ast.to)}`);
2208
+ }
2184
2209
  }
2185
2210
  }
2186
2211
  await fs.writeFile(params.tablePath(ast.to), changes.apply());