cube icon indicating copy to clipboard operation
cube copied to clipboard

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

Open liv1n9 opened this issue 1 month ago • 0 comments

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?

liv1n9 avatar Nov 26 '25 10:11 liv1n9