Skip to content

Commit

Permalink
MONDRIAN: Make member property lookup (for example SOLVE_ORDER) case …
Browse files Browse the repository at this point in the history
…INsensitive. Requested by Anton NIkitin on mailing list.

[git-p4: depot-paths = "//open/mondrian/": change = 3604]
  • Loading branch information
ebb committed May 19, 2005
1 parent ec5a5d5 commit 8d434b6
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/main/mondrian/olap/MemberProperty.java
Expand Up @@ -56,10 +56,14 @@ public void unparse(PrintWriter pw) {
exp.unparse(pw);
}

/** Retrieves a property by name from an array. **/
/**
* Retrieves a property by name from an array.
* @todo Uses a linear search, might be a performance problem if there are many properties.
**/
static Exp get(MemberProperty[] a, String name) {
for (int i = 0; i < a.length; i++) {
if (a[i].name.equals(name)) {
// TODO: add case sensitivity option
if (a[i].name.equalsIgnoreCase(name)) {
return a[i].exp;
}
}
Expand Down
28 changes: 28 additions & 0 deletions testsrc/main/mondrian/test/CompatibilityTest.java
Expand Up @@ -135,6 +135,34 @@ public void testCalculatedMemberCase() {
+ "Axis #1:" + nl + "{[Measures].[CaLc]}" + nl + "Row #0: 1" + nl);
}

/**
* Solve order is case insensitive.
*/
public void testSolveOrderCase() {
checkSolveOrder("SOLVE_ORDER");
checkSolveOrder("SoLvE_OrDeR");
checkSolveOrder("solve_order");
}

private void checkSolveOrder(String keyword) {
runQueryCheckResult(
"WITH" + nl +
" MEMBER [Store].[StoreCalc] as '0', " + keyword + "=0" + nl +
" MEMBER [Product].[ProdCalc] as '1', " + keyword + "=1" + nl +
"SELECT" + nl +
" { [Product].[ProdCalc] } ON columns," + nl +
" { [Store].[StoreCalc] } ON rows" + nl +
"FROM Sales",

"Axis #0:" + nl +
"{}" + nl +
"Axis #1:" + nl +
"{[Product].[ProdCalc]}" + nl +
"Axis #2:" + nl +
"{[Store].[StoreCalc]}" + nl +
"Row #0: 1" + nl);
}

/**
* Brackets around member names are optional.
*/
Expand Down

0 comments on commit 8d434b6

Please sign in to comment.