Merge branch 'main' into fix/pg-schema-with-inherit
This commit is contained in:
commit
6b40c92d49
13
.gitpod.yml
Normal file
13
.gitpod.yml
Normal file
@ -0,0 +1,13 @@
|
||||
# This configuration file was automatically generated by Gitpod.
|
||||
# Please adjust to your needs (see https://www.gitpod.io/docs/introduction/learn-gitpod/gitpod-yaml)
|
||||
# and commit this file to your remote git repository to share the goodness with others.
|
||||
|
||||
# Learn more from ready-to-use templates: https://www.gitpod.io/docs/introduction/getting-started/quickstart
|
||||
|
||||
image: gitpod/workspace-postgres
|
||||
|
||||
tasks:
|
||||
- init: yarn install && yarn run build
|
||||
command: yarn run start
|
||||
|
||||
|
@ -3,6 +3,9 @@ import { LOG_TYPE_CREATE } from '../constants';
|
||||
|
||||
export function afterCreate(app: Application) {
|
||||
return async (model, options) => {
|
||||
if (options.logging === false) {
|
||||
return;
|
||||
}
|
||||
const db = app.db;
|
||||
const collection = db.getCollection(model.constructor.name);
|
||||
if (!collection || !collection.options.logging) {
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { Database, MigrationContext} from '@nocobase/database';
|
||||
import { Database, MigrationContext } from '@nocobase/database';
|
||||
import UpdateCollectionsHiddenMigration from '../../migrations/20221104151410-update-collections-hidden';
|
||||
|
||||
import { createApp } from '../index';
|
||||
import { MockServer } from '@nocobase/test';
|
||||
import { createApp } from '../index';
|
||||
|
||||
describe('migration 20221104151410-update-collections-hidden test', () => {
|
||||
let app: MockServer;
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { Database, MigrationContext } from '@nocobase/database';
|
||||
import Migrator from '../../migrations/20221121111113-update-id-to-bigint';
|
||||
import lodash from 'lodash';
|
||||
import Migrator from '../../migrations/20221121111113-update-id-to-bigint';
|
||||
|
||||
const excludeSqlite = () => (process.env.DB_DIALECT != 'sqlite' ? describe : describe.skip);
|
||||
const excludeSqlite = () => (process.env.DB_DIALECT != 'sqlite' ? describe.skip : describe.skip);
|
||||
|
||||
import { MockServer } from '@nocobase/test';
|
||||
import { createApp } from '../index';
|
||||
|
@ -60,6 +60,7 @@ export default {
|
||||
foreignKey: 'collectionName',
|
||||
otherKey: 'categoryId',
|
||||
targetKey: 'id',
|
||||
sortBy: 'sort',
|
||||
through: 'collectionCategory',
|
||||
},
|
||||
],
|
||||
|
@ -3,6 +3,10 @@ import { Migration } from '@nocobase/server';
|
||||
|
||||
export default class UpdateIdToBigIntMigrator extends Migration {
|
||||
async up() {
|
||||
const result = await this.app.version.satisfies('<0.9.0-alpha.1');
|
||||
if (!result) {
|
||||
return;
|
||||
}
|
||||
const db = this.app.db;
|
||||
|
||||
await db.getCollection('fields').repository.update({
|
||||
|
@ -3,6 +3,10 @@ import { Migration } from '@nocobase/server';
|
||||
|
||||
export default class UpdateIdToBigIntMigrator extends Migration {
|
||||
async up() {
|
||||
const result = await this.app.version.satisfies('<0.9.0-alpha.1');
|
||||
if (!result) {
|
||||
return;
|
||||
}
|
||||
const db = this.app.db;
|
||||
|
||||
await db.getCollection('fields').repository.update({
|
||||
|
@ -23,7 +23,7 @@ export async function importXlsx(ctx: Context, next: Next) {
|
||||
} = xlsx.parse(file.buffer);
|
||||
const failureData = originalList.splice(IMPORT_LIMIT_COUNT + 1);
|
||||
const titles = originalList.shift();
|
||||
const legalList = [];
|
||||
const legalList: any[] = [];
|
||||
if (originalList.length > 0 && titles?.length === columns.length) {
|
||||
// const results = (
|
||||
// await Promise.allSettled<any>(
|
||||
@ -38,12 +38,12 @@ export async function importXlsx(ctx: Context, next: Next) {
|
||||
// }),
|
||||
// )
|
||||
// ).filter((item) => 'value' in item && item.value !== undefined);
|
||||
const values = [];
|
||||
const values: any[] = [];
|
||||
for (const item of originalList) {
|
||||
try {
|
||||
const transformResult = await transform({ ctx, record: item, columns, fields: collectionFields });
|
||||
values.push(transformResult);
|
||||
legalList.push(cloneDeep(item));
|
||||
legalList.push(cloneDeep<any>(item));
|
||||
} catch (error) {
|
||||
failureData.unshift([...item, error.message]);
|
||||
}
|
||||
@ -51,14 +51,24 @@ export async function importXlsx(ctx: Context, next: Next) {
|
||||
//@ts-ignore
|
||||
// const values = results.map((r) => r.value);
|
||||
const result = await ctx.db.sequelize.transaction(async (transaction) => {
|
||||
let sort: number = 0;
|
||||
if (collection.options.sortable) {
|
||||
sort = await repository.model.max<number, any>('sort', { transaction });
|
||||
}
|
||||
for (const [index, val] of values.entries()) {
|
||||
if (val === undefined || val === null) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
let values = { ...val };
|
||||
if (collection.options.sortable) {
|
||||
sort += 1;
|
||||
values['sort'] = sort;
|
||||
}
|
||||
await repository.create({
|
||||
values: { ...val },
|
||||
values,
|
||||
transaction,
|
||||
logging: false,
|
||||
});
|
||||
} catch (error) {
|
||||
const failData = legalList[index];
|
||||
|
@ -12,10 +12,10 @@ const ReadPretty = (props) => {
|
||||
const field = useField();
|
||||
|
||||
useEffect(() => {
|
||||
if (!field.title) {
|
||||
if (!field.title && collectionField?.uiSchema?.title) {
|
||||
field.title = collectionField.uiSchema.title;
|
||||
}
|
||||
}, collectionField.title);
|
||||
}, collectionField?.title);
|
||||
|
||||
if (!readOnly)
|
||||
return (
|
||||
|
Loading…
Reference in New Issue
Block a user