[Jifty-commit] r5680 - Jifty-DBI/branches/tisql/lib/Jifty/DBI
Jifty commits
jifty-commit at lists.jifty.org
Mon Aug 11 00:03:31 EDT 2008
Author: ruz
Date: Mon Aug 11 00:03:10 2008
New Revision: 5680
Modified:
Jifty-DBI/branches/tisql/lib/Jifty/DBI/Collection.pm
Log:
* add optional 'join' argument to open_paren and close_paren,
so you can build arbitrary trees in join clauses
* drop support of 'none' aggregator as it is stupid,
never was documented, never worked as expected with
parens
Modified: Jifty-DBI/branches/tisql/lib/Jifty/DBI/Collection.pm
==============================================================================
--- Jifty-DBI/branches/tisql/lib/Jifty/DBI/Collection.pm (original)
+++ Jifty-DBI/branches/tisql/lib/Jifty/DBI/Collection.pm Mon Aug 11 00:03:10 2008
@@ -161,7 +161,6 @@
count_all
subclauses
restrictions
- _open_parens
criteria_count
);
@@ -1349,16 +1348,18 @@
};
# Juju because this should come _AFTER_ the EA
- my @prefix;
- if ( $self->{'_open_parens'}{$clause_id} ) {
- @prefix = ('(') x delete $self->{'_open_parens'}{$clause_id};
- }
-
- if ( lc( $args{'entry_aggregator'} || "" ) eq 'none' || !@$restriction ) {
- @$restriction = ( @prefix, $clause );
- } else {
- push @$restriction, $args{'entry_aggregator'}, @prefix, $clause;
+ if ( @$restriction ) {
+ if ( $restriction->[-1] eq '(' ) {
+ for my $i ( reverse 0 .. (@$restriction-1) ) {
+ next if $restriction->[-1] eq '(';
+ splice @$restriction, $i-1, 0, $args{'entry_aggregator'};
+ last;
+ }
+ } else {
+ push @$restriction, $args{'entry_aggregator'};
+ }
}
+ push @$restriction, $clause;
# We're now limited. people can do searches.
@@ -1411,8 +1412,14 @@
=cut
sub open_paren {
- my ( $self, $clause ) = @_;
- $self->{_open_parens}{$clause}++;
+ my ( $self, $clause, $join ) = @_;
+ my $restriction;
+ if ( $join ) {
+ $restriction = $self->{'joins'}{ $join }{'criteria'}{ $clause } ||= [];
+ } else {
+ $restriction = $self->{'restrictions'}{$clause} ||= [];
+ }
+ push @$restriction, '(';
}
=head2 close_paren CLAUSE
@@ -1427,8 +1434,13 @@
# Immediate Action
sub close_paren {
- my ( $self, $clause ) = @_;
- my $restriction = $self->{'restrictions'}{$clause} ||= [];
+ my ( $self, $clause, $join ) = @_;
+ my $restriction;
+ if ( $join ) {
+ $restriction = $self->{'joins'}{ $join }{'criteria'}{ $clause } ||= [];
+ } else {
+ $restriction = $self->{'restrictions'}{$clause} ||= [];
+ }
push @$restriction, ')';
}
More information about the Jifty-commit
mailing list