Skip to content

Commit f5e69f7

Browse files
authored
fix(schema-compiler): Fix model validation for aliased included members for views (#9398)
1 parent 41e4d93 commit f5e69f7

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

packages/cubejs-schema-compiler/src/compiler/CubeValidator.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -792,8 +792,8 @@ const viewSchema = inherit(baseSchema, {
792792
Joi.array().items(Joi.alternatives([
793793
Joi.string().required(),
794794
Joi.object().keys({
795-
name: Joi.string().required(),
796-
alias: Joi.string()
795+
name: identifier.required(),
796+
alias: identifier
797797
})
798798
]))
799799
]).required(),

packages/cubejs-schema-compiler/test/unit/cube-validator.test.ts

+31
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,37 @@ describe('Cube Validation', () => {
134134
expect(validationResult.error).toBeFalsy();
135135
});
136136

137+
it('view with incorrect included member with alias', async () => {
138+
const cubeValidator = new CubeValidator(new CubeSymbols());
139+
const cube = {
140+
name: 'name',
141+
// it's a hidden field which we use internally
142+
isView: true,
143+
fileName: 'fileName',
144+
cubes: [
145+
{
146+
joinPath: () => '',
147+
prefix: false,
148+
includes: [
149+
'member-by-name',
150+
{
151+
name: 'member-by-alias',
152+
alias: 'incorrect Alias'
153+
}
154+
]
155+
}
156+
]
157+
};
158+
159+
const validationResult = cubeValidator.validate(cube, {
160+
error: (message: any, _e: any) => {
161+
console.log(message);
162+
}
163+
} as any);
164+
165+
expect(validationResult.error).toBeTruthy();
166+
});
167+
137168
it('refreshKey alternatives', async () => {
138169
const cubeValidator = new CubeValidator(new CubeSymbols());
139170
const cube = {

0 commit comments

Comments
 (0)