Fix for #639
This commit is contained in:
parent
d247893d31
commit
8cd01fe99e
3 changed files with 23 additions and 3 deletions
|
@ -1373,7 +1373,7 @@ const withForm = createComponentMixin([], [], (TargetClass, InnerClass) => {
|
|||
const savedData = self.state.formState.get('savedData');
|
||||
|
||||
function isDifferent(data1, data2, prefix) {
|
||||
if (typeof data1 === 'object' && typeof data2 === 'object') {
|
||||
if (typeof data1 === 'object' && typeof data2 === 'object' && data1 && data2) {
|
||||
const keys = new Set([...Object.keys(data1), ...Object.keys(data2)]);
|
||||
for (const key of keys) {
|
||||
if (isDifferent(data1[key], data2[key], `${prefix}/${key}`)) {
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
const knex = require('../lib/knex');
|
||||
const hasher = require('node-object-hash')();
|
||||
const slugify = require('slugify');
|
||||
const { enforce, filterObject } = require('../lib/helpers');
|
||||
const dtHelpers = require('../lib/dt-helpers');
|
||||
const interoperableErrors = require('../../shared/interoperable-errors');
|
||||
|
@ -543,7 +542,7 @@ async function createTx(tx, context, listId, entity) {
|
|||
|
||||
let columnName;
|
||||
if (!fieldType.grouped) {
|
||||
columnName = ('custom_' + slugify(entity.name, '_') + '_' + shortid.generate()).toLowerCase().replace(/[^a-z0-9_]/g, '');
|
||||
columnName = ('custom_' + '_' + shortid.generate()).toLowerCase().replace(/[^a-z0-9_]/g, '_');
|
||||
}
|
||||
|
||||
const filteredEntity = filterObject(entity, allowedKeysCreate);
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
const shortid = require('shortid');
|
||||
|
||||
exports.up = (knex, Promise) => (async() => {
|
||||
const fields = await knex('custom_fields').whereNotNull('column');
|
||||
|
||||
for (const field of fields) {
|
||||
const listId = field.list;
|
||||
const oldName = field.column;
|
||||
const newName = ('custom_' + '_' + shortid.generate()).toLowerCase().replace(/[^a-z0-9_]/g, '_');
|
||||
|
||||
await knex('custom_fields').where('id', field.id).update('column', newName);
|
||||
|
||||
await knex.schema.table('subscription__' + listId, table => {
|
||||
table.renameColumn(oldName, newName);
|
||||
table.renameColumn('source_' + oldName, 'source_' + newName);
|
||||
});
|
||||
}
|
||||
})();
|
||||
|
||||
exports.down = (knex, Promise) => (async() => {
|
||||
})();
|
Loading…
Add table
Add a link
Reference in a new issue