tsnoad / Irondata

Data warehouse report generator
4 stars 1 forks source link

Query integrity: if Tabular::query() joins the same table multiple times. #11

Open tsnoad opened 14 years ago

tsnoad commented 14 years ago

For a report, if there are multiple constraints using the same table, Tabular::query() will join the table multiple times. This may give unexpected results for the user. Example: a report with the constraints (division='melbourne' or division='sydney'). This report could return results because, for a given member, there may be multiple membership entries - one when a member was part of the melbourne division, and one when they were part of the sydney division.

In this case the join should only be made once, and all the constraints should reference the joined table.

For the report to behave as expected, it may also be necessary to have a constraint along the lines of membership.end_date='infinity' to ensue that only the latest entry in the membership table is used.