mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-07-01 18:52:20 +08:00
fix: restore with table name in camel case (#3995)
This commit is contained in:
parent
773b7aef52
commit
1e0501cd96
@ -124,7 +124,7 @@ export default class MysqlQueryInterface extends QueryInterface {
|
||||
}): Promise<void> {
|
||||
const { tableInfo, columnName, seqName, currentVal, transaction } = options;
|
||||
|
||||
const sql = `ALTER TABLE ${tableInfo.tableName} AUTO_INCREMENT = ${currentVal};`;
|
||||
const sql = `ALTER TABLE ${this.quoteIdentifier(tableInfo.tableName)} AUTO_INCREMENT = ${currentVal};`;
|
||||
await this.db.sequelize.query(sql, { transaction });
|
||||
}
|
||||
}
|
||||
|
@ -64,4 +64,9 @@ export default abstract class QueryInterface {
|
||||
currentVal: number;
|
||||
transaction?: Transaction;
|
||||
}): Promise<void>;
|
||||
|
||||
public quoteIdentifier(identifier: string) {
|
||||
// @ts-ignore
|
||||
return this.db.sequelize.getQueryInterface().queryGenerator.quoteIdentifier(identifier);
|
||||
}
|
||||
}
|
||||
|
@ -828,4 +828,66 @@ describe('dumper', () => {
|
||||
|
||||
expect(dumpableCollections.custom).toBeDefined();
|
||||
});
|
||||
|
||||
it('should dump and restore with table named by camel case', async () => {
|
||||
await app.db.getRepository('collections').create({
|
||||
values: {
|
||||
name: 'Resumes-Table',
|
||||
fields: [
|
||||
{
|
||||
name: 'stringField',
|
||||
type: 'string',
|
||||
},
|
||||
],
|
||||
},
|
||||
context: {},
|
||||
});
|
||||
|
||||
await app.db.getRepository('Resumes-Table').create({
|
||||
values: [
|
||||
{
|
||||
stringField: 'test',
|
||||
},
|
||||
{
|
||||
stringField: 'test2',
|
||||
},
|
||||
],
|
||||
});
|
||||
await app.db.getRepository('collections').create({
|
||||
values: {
|
||||
name: 'Photos',
|
||||
fields: [
|
||||
{
|
||||
name: 'stringField',
|
||||
type: 'string',
|
||||
},
|
||||
],
|
||||
},
|
||||
context: {},
|
||||
});
|
||||
|
||||
await app.db.getRepository('Photos').create({
|
||||
values: [
|
||||
{
|
||||
stringField: 'test',
|
||||
},
|
||||
{
|
||||
stringField: 'test2',
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
const dumper = new Dumper(app);
|
||||
const result = await dumper.dump({
|
||||
groups: new Set(['required', 'custom']),
|
||||
});
|
||||
|
||||
const restorer = new Restorer(app, {
|
||||
backUpFilePath: result.filePath,
|
||||
});
|
||||
|
||||
await restorer.restore({
|
||||
groups: new Set(['required', 'custom']),
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user