rake-db 2.27.20 → 2.27.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.mjs CHANGED
@@ -3220,14 +3220,14 @@ const quoteCustomType = (s) => {
3220
3220
  const [schema, type] = getSchemaAndTableFromName(s);
3221
3221
  return schema ? '"' + schema + '".' + type : type;
3222
3222
  };
3223
- const quoteSchemaTable = (arg) => {
3224
- return singleQuote(concatSchemaAndName(arg));
3223
+ const quoteSchemaTable = (arg, excludeCurrentSchema) => {
3224
+ return singleQuote(concatSchemaAndName(arg, excludeCurrentSchema));
3225
3225
  };
3226
3226
  const concatSchemaAndName = ({
3227
3227
  schema,
3228
3228
  name
3229
- }) => {
3230
- return schema ? `${schema}.${name}` : name;
3229
+ }, excludeCurrentSchema) => {
3230
+ return schema && schema !== excludeCurrentSchema ? `${schema}.${name}` : name;
3231
3231
  };
3232
3232
  const makePopulateEnumQuery = (item) => {
3233
3233
  const [schema, name] = getSchemaAndTableFromName(item.enumName);
@@ -4317,7 +4317,7 @@ const instantiateDbColumn = (ctx, data, domains, dbColumn) => {
4317
4317
  if (enumType) {
4318
4318
  column = new EnumColumn(
4319
4319
  ctx.columnSchemaConfig,
4320
- typeId,
4320
+ typeSchema === ctx.currentSchema ? typeName : typeId,
4321
4321
  enumType.values,
4322
4322
  ctx.columnSchemaConfig.type
4323
4323
  );
@@ -5250,24 +5250,27 @@ const astEncoders = {
5250
5250
  addCode(code, ");");
5251
5251
  return code;
5252
5252
  },
5253
- enum(ast) {
5254
- return `await db.${ast.action === "create" ? "createEnum" : "dropEnum"}(${quoteSchemaTable(ast)}, [${ast.values.map(singleQuote).join(", ")}]);`;
5253
+ enum(ast, _, currentSchema) {
5254
+ return `await db.${ast.action === "create" ? "createEnum" : "dropEnum"}(${quoteSchemaTable(ast, currentSchema)}, [${ast.values.map(singleQuote).join(", ")}]);`;
5255
5255
  },
5256
- enumValues(ast) {
5256
+ enumValues(ast, _, currentSchema) {
5257
5257
  return `await db.${ast.action}EnumValues(${quoteSchemaTable(
5258
- ast
5258
+ ast,
5259
+ currentSchema
5259
5260
  )}, [${ast.values.map(singleQuote).join(", ")}]);`;
5260
5261
  },
5261
- renameEnumValues(ast, config) {
5262
+ renameEnumValues(ast, config, currentSchema) {
5262
5263
  return `await db.renameEnumValues(${quoteSchemaTable(
5263
- ast
5264
+ ast,
5265
+ currentSchema
5264
5266
  )}, { ${Object.entries(ast.values).map(
5265
5267
  ([from, to]) => `${quoteObjectKey(from, config.snakeCase)}: ${singleQuote(to)}`
5266
5268
  ).join(", ")} });`;
5267
5269
  },
5268
- changeEnumValues(ast) {
5270
+ changeEnumValues(ast, _, currentSchema) {
5269
5271
  return `await db.changeEnumValues(${quoteSchemaTable(
5270
- ast
5272
+ ast,
5273
+ currentSchema
5271
5274
  )}, [${ast.fromValues.map(singleQuote).join(", ")}], [${ast.toValues.map(singleQuote).join(", ")}]);`;
5272
5275
  },
5273
5276
  domain(ast, _, currentSchema) {