From 55101cde81595a0eddd03c2a2aa6f9c4c7f840fe Mon Sep 17 00:00:00 2001 From: miker Date: Mon, 18 Sep 2006 03:17:43 +0000 Subject: [PATCH] initial test script for the SQLBuilder git-svn-id: svn://svn.open-ils.org/ILS/trunk@6128 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../examples/reporter-sql-builder-test.pl | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100755 Open-ILS/examples/reporter-sql-builder-test.pl diff --git a/Open-ILS/examples/reporter-sql-builder-test.pl b/Open-ILS/examples/reporter-sql-builder-test.pl new file mode 100755 index 0000000000..71e109c359 --- /dev/null +++ b/Open-ILS/examples/reporter-sql-builder-test.pl @@ -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; + -- 2.43.2