fix(bi): fix T-2643 (#3101)

This commit is contained in:
YANG QIA 2023-11-27 16:24:47 +08:00 committed by GitHub
parent cbcf70e587
commit 6819366049
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,5 @@
import { Context, Next } from '@nocobase/actions';
import { Field, FilterParser, snakeCase } from '@nocobase/database';
import ChartsV2Plugin from '../plugin';
import { formatter } from './formatter';
import compose from 'koa-compose';
import { parseFilter, getDateVars } from '@nocobase/utils';
@ -169,7 +168,6 @@ export const parseFieldAndAssociations = async (ctx: Context, next: Next) => {
const { collection: collectionName, measures, dimensions, orders, filter } = ctx.action.params.values as QueryParams;
const collection = ctx.db.getCollection(collectionName);
const fields = collection.fields;
const underscored = collection.options.underscored;
const models: {
[target: string]: {
type: string;
@ -185,7 +183,8 @@ export const parseFieldAndAssociations = async (ctx: Context, next: Next) => {
} else if (selected.field.length > 1) {
[target, name] = selected.field;
}
let field = underscored ? snakeCase(name) : name;
const rawAttributes = collection.model.getAttributes();
let field = rawAttributes[name]?.field || name;
let fieldType = fields.get(name)?.type;
if (target) {
const targetField = fields.get(target) as Field;