Skip to content

API error "One or more Primary key is required for '${cubeName}' cube" even when allowUngroupedWithoutPrimaryKey set to true #10181

@liv1n9

Description

@liv1n9

Problem

I already set allowUngroupedWithoutPrimaryKey in cube.js, but query with ungrouped: true still get error: "One or more Primary key is required for '${cubeName}' cube"

In BaseQuery.js, i found:

/**
 *
 * @param {string} cubeName
 * @returns {Array<string>}
 */
primaryKeyNames(cubeName) {
    const primaryKeys = this.cubeEvaluator.primaryKeys[cubeName];
    if (!primaryKeys || !primaryKeys.length) {
        throw new UserError_1.UserError(`One or more Primary key is required for '${cubeName}' cube`);
    }
    return primaryKeys.map((pk) => this.primaryKeyName(cubeName, pk));
}

primaryKeyNames always throws an error when a cube has no primary key. But shouldn’t it check allowUngroupedWithoutPrimaryKey !== true first?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionThe issue is a question. Please use Stack Overflow for questions.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions