From 22a146e60cc45c023a7e05a06e4d5ef8ddc1a92e Mon Sep 17 00:00:00 2001 From: miker Date: Fri, 29 Sep 2006 04:06:01 +0000 Subject: [PATCH] more has_many/might_have work git-svn-id: svn://svn.open-ils.org/ILS/trunk@6262 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/examples/reporter-sql-builder-test.pl | 14 ++++++++++++ .../src/perlmods/OpenILS/Reporter/SQLBuilder.pm | 26 +++++++++++++++++----- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/Open-ILS/examples/reporter-sql-builder-test.pl b/Open-ILS/examples/reporter-sql-builder-test.pl index 36828b6c25..846c5c0fa0 100755 --- a/Open-ILS/examples/reporter-sql-builder-test.pl +++ b/Open-ILS/examples/reporter-sql-builder-test.pl @@ -22,6 +22,10 @@ my $report = { column => { transform => count => colname => 'id' }, alias => '::PARAM3', }, + { relation=> 'circ-id-mb', + column => { transform => sum => colname => 'amount' }, + alias => 'total bills', + }, ], from => { table => 'action.circulation', @@ -44,6 +48,11 @@ my $report = { alias => 'circ-checkin_lib-aou', key => 'id', }, + 'id-billings' => { + table => 'money.billing', + alias => 'circ-id-mb', + key => 'xact', + }, }, }, where => [ @@ -55,6 +64,10 @@ my $report = { column => { transform => month_trunc => colname => 'checkin_time' }, condition => { 'in' => '::PARAM2' }, }, + { relation => 'circ-id-mb', + column => 'voided', + condition => { '=' => '::PARAM7' }, + }, ], having => [ { relation => 'circ', @@ -88,6 +101,7 @@ my $params = { PARAM4 => 'Checkin Date', PARAM5 => [{ transform => 'Bare', params => [10] },{ transform => 'Bare', params => [100] }], PARAM6 => [ 1, 4 ], + PARAM7 => 'f', }; my $r = OpenILS::Reporter::SQLBuilder->new; diff --git a/Open-ILS/src/perlmods/OpenILS/Reporter/SQLBuilder.pm b/Open-ILS/src/perlmods/OpenILS/Reporter/SQLBuilder.pm index ac39e37883..915a37d0f3 100644 --- a/Open-ILS/src/perlmods/OpenILS/Reporter/SQLBuilder.pm +++ b/Open-ILS/src/perlmods/OpenILS/Reporter/SQLBuilder.pm @@ -35,12 +35,15 @@ sub resolve_param { my $self = shift; my $val = shift; - if ($val =~ /^::(.+)$/o) { + if (defined($val) && $val =~ /^::(.+)$/o) { $val = $self->get_param($1); } - $val =~ s/\\/\\\\/go if (!ref($val)); - $val =~ s/"/\\"/go if (!ref($val)); + if (defined($val) && !ref($val)) { + $val =~ s/\\/\\\\/go; + $val =~ s/"/\\"/go; + } + return $val; } @@ -257,12 +260,15 @@ sub new { } else { $self->{_transform} = 'GenericTransform'; } - } else { + } elsif( defined($col_data) ) { $self->{_transform} = 'Bare'; $self->{params} = $col_data; + } else { + $self->{_transform} = 'NULL'; } + return $self; } @@ -276,6 +282,14 @@ sub toSQL { #------------------------------------------------------------------------------------------------- +package OpenILS::Reporter::SQLBuilder::Input::Transform::NULL; + +sub toSQL { + return "NULL"; +} + + +#------------------------------------------------------------------------------------------------- package OpenILS::Reporter::SQLBuilder::Input::Transform::Bare; sub toSQL { @@ -378,8 +392,10 @@ sub new { } else { $self->{_transform} = 'GenericTransform'; } - } else { + } elsif( defined($self->{_column}) ) { $self->{_transform} = 'Bare'; + } else { + $self->{_transform} = 'NULL'; } -- 2.11.0