@@ -116,10 +116,12 @@ public void testParseIdentifier() {
116
116
117
117
/**
118
118
* Tests that escaped single quotes ('') nested inside a quoted
119
- * part of a query are unparsed as escaped quotes as well.
119
+ * part of a query are handled correctly. The MDX language allows
120
+ * expressions for calculated members and sets to be specified with and
121
+ * without single quotes; the unparser generates expressions without quotes.
120
122
*/
121
123
public void testQuoteEscaping () {
122
- final String query =
124
+ String query =
123
125
"WITH\n "
124
126
+ "MEMBER [CustomerDim].[CustomerName].[XL_QZX] AS 'Aggregate"
125
127
+ "({[CustomerDim].[CustomerName].&[ABC INT''L],"
@@ -129,8 +131,29 @@ public void testQuoteEscaping() {
129
131
+ "FROM [cube]\n "
130
132
+ "WHERE ([CustomerDim].[CustomerName].[XL_QZX])" ;
131
133
final MdxParser parser = new DefaultMdxParserImpl ();
132
- final SelectNode rootNode = parser .parseSelect (query );
133
- assertEquals (query ,TestContext .unfold (rootNode .toString ()));
134
+ SelectNode rootNode = parser .parseSelect (query );
135
+ TestContext .assertEqualsVerbose (
136
+ "WITH\n "
137
+ + "MEMBER [CustomerDim].[CustomerName].[XL_QZX] AS\n "
138
+ + " Aggregate({[CustomerDim].[CustomerName].&[ABC INT'L], [CustomerDim].[CustomerName].&[XYZ]})\n "
139
+ + "SELECT\n "
140
+ + "{[Measures].[Sales]} ON COLUMNS\n "
141
+ + "FROM [cube]\n "
142
+ + "WHERE ([CustomerDim].[CustomerName].[XL_QZX])" ,
143
+ rootNode .toString ());
144
+
145
+ // Now named set
146
+ query =
147
+ "WITH SET Foo as Filter(Bar.Members, Instr(Name, \" '\" ) > 0)\n "
148
+ + "SELECT FROM [Cube]" ;
149
+ rootNode = parser .parseSelect (query );
150
+ TestContext .assertEqualsVerbose (
151
+ "WITH\n "
152
+ + "SET Foo AS\n "
153
+ + " Filter(Bar.Members, (Instr(Name, \" '\" ) > 0.0))\n "
154
+ + "SELECT\n "
155
+ + "FROM [Cube]" ,
156
+ rootNode .toString ());
134
157
}
135
158
}
136
159
0 commit comments