Skip to content

Commit f6d2531

Browse files
authored
uses crossjoin instead of * (#43)
1 parent 63c552b commit f6d2531

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

Diff for: lib/mondrian_rest/query_helper.rb

+9-1
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,15 @@ def build_query(cube, options = {})
265265

266266
unless dd.empty?
267267
# Cross join all the drilldowns
268-
axis_exp = dd.join(' * ')
268+
axis_exp = if dd.size == 1
269+
dd
270+
else dd.size > 1
271+
cross = "Crossjoin(#{dd.pop(2).join(', ')})"
272+
while !dd.empty?
273+
cross = "Crossjoin(#{dd.pop}, #{cross})"
274+
end
275+
cross
276+
end
269277

270278
# Apply filters
271279
unless filters.empty?

Diff for: spec/api_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ def app
189189
get '/cubes/Sales/aggregate?drilldown[]=Time.Month&drilldown[]=Customers.City&measures[]=Store%20Sales&debug=true'
190190
r = JSON.parse(last_response.body)
191191
expect(r.has_key?('mdx')).to be(true)
192-
expect(r['mdx']).to eq("SELECT {[Measures].[Store Sales]} ON COLUMNS,\n[Time].[Time].[Month].Members * [Customers].[Customers].[City].Members ON ROWS\nFROM [Sales]")
192+
expect(r['mdx']).to eq("SELECT {[Measures].[Store Sales]} ON COLUMNS,\nCrossjoin([Time].[Time].[Month].Members, [Customers].[Customers].[City].Members) ON ROWS\nFROM [Sales]")
193193
end
194194

195195
it "should not include the generated MDX in the response if debug not given or if debug=false" do

0 commit comments

Comments
 (0)