Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • by Ovid (2709) on 2008.05.16 9:16 (#62897) Homepage Journal

    Years ago I worked on a very impressive ORM that was written in-house (not by me). It had lots of kinks, but one of the nice things was something like this:

    "Gimme a report of sales per store in Texas, per salesman."

    Um, OK.

    # The actual API was different
    my $dataset = dataset({
        data  => [qw/sales store salesman/],
        where => { state => 'Texas' },
        group => ['salesman'],

    Notice anything interesting? There's no FROM or complicated joins. You just told it to give you the damned data. By requiring FK constraints to describe relationships (and forcing people to use fully-qualified names if ambiguities occur), you can infer the 'from'. Sometimes the fields we asked for didn't even exist. They were virtual fields that were calculated on the fly.

    The above example might have to join stores to salesman to get the salesman and join stores to orders and the latter to order_items to get the actual sales, but the programmer didn't care.

    This required that we be very careful about writing out our relationships, but it worked fairly well and made the bulk of our reporting very, very simple (you'd want a more robust query then our primitive WHERE statements. Perhaps the Google Query Language [] might be a start).