Skip to content

Commit

Permalink
MONDRIAN: [MONDRIAN-943] [MONDRIAN-465] Integration of fixes from the…
Browse files Browse the repository at this point in the history
… main branch.

[git-p4: depot-paths = "//open/mondrian-release/3.2.2/": change = 14297]
  • Loading branch information
lucboudreau committed May 19, 2011
1 parent 88c3b7e commit fb4a0b1
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/main/mondrian/rolap/SqlTupleReader.java
Expand Up @@ -992,17 +992,17 @@ protected void addLevelMemberSql(
sqlQuery.addGroupBy(keySql, alias);
}

if (!ordinalSql.equals(keySql)) {
alias = sqlQuery.addSelect(ordinalSql);
if (captionSql != null) {
alias = sqlQuery.addSelect(captionSql);
if (needsGroupBy) {
sqlQuery.addGroupBy(ordinalSql, alias);
sqlQuery.addGroupBy(captionSql, alias);
}
}

if (captionSql != null) {
alias = sqlQuery.addSelect(captionSql);
if (!ordinalSql.equals(keySql)) {
alias = sqlQuery.addSelect(ordinalSql);
if (needsGroupBy) {
sqlQuery.addGroupBy(captionSql, alias);
sqlQuery.addGroupBy(ordinalSql, alias);
}
}

Expand Down
60 changes: 60 additions & 0 deletions testsrc/main/mondrian/test/BasicQueryTest.java
Expand Up @@ -7007,6 +7007,66 @@ public void testDirectMemberReferenceOnDimensionWithCalculationsDefined() {
+ "{[Gender].[M]}\n"
+ "Row #0: 135,215\n");
}

public void testCaptionColumnUsedWithOrdinalColumn() throws Exception {
final TestContext context =
TestContext.createSubstitutingCube(
"HR",
" <Dimension name=\"FooBarDimension\" foreignKey=\"employee_id\">\n"
+ " <Hierarchy hasAll=\"false\" primaryKey=\"position_id\">\n"
+ " <Table name=\"position\"/>\n"
+ " <Level name=\"FooBarLevel\" uniqueMembers=\"true\"\n"
+ " column=\"position_id\""
+ " captionColumn=\"position_title\""
+ " ordinalColumn=\"management_role\""
+ " />\n"
+ " </Hierarchy>\n"
+ " </Dimension>\n",
null,
null,
null);
context.assertQueryReturns(
"select {[FooBarDimension].[FooBarLevel].Members} on columns from [HR]",
"Axis #0:\n"
+ "{}\n"
+ "Axis #1:\n"
+ "{[FooBarDimension].[9]}\n"
+ "{[FooBarDimension].[8]}\n"
+ "{[FooBarDimension].[6]}\n"
+ "{[FooBarDimension].[7]}\n"
+ "{[FooBarDimension].[1]}\n"
+ "{[FooBarDimension].[2]}\n"
+ "{[FooBarDimension].[5]}\n"
+ "{[FooBarDimension].[4]}\n"
+ "{[FooBarDimension].[3]}\n"
+ "{[FooBarDimension].[14]}\n"
+ "{[FooBarDimension].[19]}\n"
+ "{[FooBarDimension].[15]}\n"
+ "{[FooBarDimension].[17]}\n"
+ "{[FooBarDimension].[16]}\n"
+ "{[FooBarDimension].[12]}\n"
+ "{[FooBarDimension].[11]}\n"
+ "{[FooBarDimension].[13]}\n"
+ "{[FooBarDimension].[18]}\n"
+ "Row #0: \n"
+ "Row #0: \n"
+ "Row #0: $270.00\n"
+ "Row #0: $162.00\n"
+ "Row #0: $864.00\n"
+ "Row #0: $432.00\n"
+ "Row #0: \n"
+ "Row #0: \n"
+ "Row #0: \n"
+ "Row #0: \n"
+ "Row #0: \n"
+ "Row #0: \n"
+ "Row #0: \n"
+ "Row #0: \n"
+ "Row #0: \n"
+ "Row #0: \n"
+ "Row #0: \n"
+ "Row #0: \n");
}
}

// End BasicQueryTest.java

0 comments on commit fb4a0b1

Please sign in to comment.