Author: spadkins
Date: Mon Oct 16 10:41:53 2006
New Revision: 7945
Modified:
p5ee/trunk/App-Repository/lib/App/Repository/DBI.pm
Log:
added {table}{$table}{param}{$param}{method} attribute to support custom
processing of non-column params
Modified: p5ee/trunk/App-Repository/lib/App/Repository/DBI.pm
==============================================================================
--- p5ee/trunk/App-Repository/lib/App/Repository/DBI.pm (original)
+++ p5ee/trunk/App-Repository/lib/App/Repository/DBI.pm Mon Oct 16 10:41:53 2006
@@ -929,24 +929,41 @@
$direction = $options->{direction} || $options->{directions}; #
{directions} is deprecated
my $modifier = $options->{distinct} ? " distinct" : "";
- # DETERMINE THE ORDER TO PROCESS THE PARAMS
- $param_order = $params->{"_order"};
- if (!defined $param_order) {
- $param_order = [ (keys %$params) ];
- }
+ my ($where_condition, @join_conditions, @criteria_conditions, $repop,
$sqlop, $value);
+
# ADD ANY DEFAULT PARAMS
my $paramdefs = $self->{table}{$table}{param};
+ my $params_modified = 0;
if ($paramdefs) {
- my $params_modified = 0;
+ # make a copy.
+ # This is necessary if {default} is supplied (see the few lines above)
+ # or if the {method} (see way below) is called to modify the $params.
my %params = %$params;
+ $params = \%params;
+
foreach $param (keys %$paramdefs) {
if (! exists $params->{$param} && $paramdefs->{$param}{default}) {
$params{$param} = $paramdefs->{$param}{default};
- push(@$param_order, $param);
+ $params_modified = 1;
+ }
+ elsif (exists $params->{$param} && $paramdefs->{$param}{method}) {
+ my $method = $paramdefs->{$param}{method};
+ my $param_clause = $self->$method($params, $param, $table);
+ if ($param_clause) {
+ push(@criteria_conditions, $param_clause);
+ }
$params_modified = 1;
}
}
- $params = \%params if ($params_modified);
+ }
+
+ # DETERMINE THE ORDER TO PROCESS THE PARAMS
+ $param_order = $params->{"_order"};
+ if (!defined $param_order) {
+ $param_order = [ (keys %$params) ];
+ }
+ elsif ($params_modified) {
+ # TODO: go into a merge between added params and predetermined ordered
params
}
my $startrow = $options->{startrow} || 0;
@@ -1242,7 +1259,6 @@
">" => "gt",
);
- my ($where_condition, @join_conditions, @criteria_conditions, $repop,
$sqlop, $value);
my ($include_null, $inferred_op);
for ($idx = 0; $idx <= $#$param_order; $idx++) {