initial test script for the SQLBuilder
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 18 Sep 2006 03:17:43 +0000 (03:17 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 18 Sep 2006 03:17:43 +0000 (03:17 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@6128 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/examples/reporter-sql-builder-test.pl [new file with mode: 0755]

diff --git a/Open-ILS/examples/reporter-sql-builder-test.pl b/Open-ILS/examples/reporter-sql-builder-test.pl
new file mode 100755 (executable)
index 0000000..71e109c
--- /dev/null
@@ -0,0 +1,74 @@
+#!/usr/bin/perl
+use diagnostics;
+use warnings;
+use strict;
+use OpenILS::Reporter::SQLBuilder;
+
+my $report = {
+       select => [
+               {       relation=> 'circ',
+                       column  => { date => 'checkin_time' },
+                       alias   => '::PARAM4',
+               },
+               {       relation=> 'circ-checkin_lib-aou',
+                       column  => 'shortname',
+                       alias   => 'Library Short Name',
+               },
+               {       relation=> 'circ-circ_staff-au-card-ac',
+                       column  => 'barcode',
+                       alias   => 'User Barcode',
+               },
+               {       relation=> 'circ',
+                       column  => { count => 'id' },
+                       alias   => '::PARAM3',
+               },
+       ],
+       from => {
+               table   => 'action.circulation',
+               alias   => 'circ',
+               join    => {
+                       checkin_staff => {
+                               table   => 'actor.usr',
+                               alias   => 'circ-circ_staff-au',
+                               key     => 'id',
+                               join    => {
+                                       card => {
+                                               table   => 'actor.card',
+                                               alias   => 'circ-circ_staff-au-card-ac',
+                                               key     => 'id',
+                                       },
+                               },
+                       },
+                       checkin_lib => {
+                               table   => 'actor.org_unit',
+                               alias   => 'circ-checkin_lib-aou',
+                               key     => 'id',
+                       },
+               },
+       },
+       where => [
+               {       relation        => 'circ-checkin_lib-aou',
+                       column          => 'id',
+                       condition       => { 'in' => '::PARAM1' },
+               },
+               {       relation        => 'circ',
+                       column          => 'checkin_time',
+                       condition       => { between => '::PARAM2' },
+               },
+       ],
+};
+
+my $params = {
+       PARAM1 => [ 1, 2, 3, 4, 5, 6 ],
+       PARAM2 => [ '2006-09-01', '2006-10-01' ],
+       PARAM3 => 'Circ Count',
+       PARAM4 => 'Checkin Date',
+};
+
+my $r = OpenILS::Reporter::SQLBuilder->new;
+
+$r->register_params( $params );
+$r->parse_report( $report );
+
+print $r->toSQL;
+