[Rt-commit] r4340 - Jifty-DBI/trunk/lib/Jifty/DBI
autrijus at bestpractical.com
autrijus at bestpractical.com
Wed Dec 21 19:46:04 EST 2005
Author: autrijus
Date: Wed Dec 21 19:46:03 2005
New Revision: 4340
Modified:
Jifty-DBI/trunk/lib/Jifty/DBI/Collection.pm
Jifty-DBI/trunk/lib/Jifty/DBI/Handle.pm
Log:
* ->join now takes optional "operator" to allow joining with
something other than equality.
* improved and fixed join documentations.
Modified: Jifty-DBI/trunk/lib/Jifty/DBI/Collection.pm
==============================================================================
--- Jifty-DBI/trunk/lib/Jifty/DBI/Collection.pm (original)
+++ Jifty-DBI/trunk/lib/Jifty/DBI/Collection.pm Wed Dec 21 19:46:03 2005
@@ -1008,7 +1008,7 @@
goto &group_by;
}
-=head2 group_by_cols EMPTY|HASH|ARRAY_OF_HASHES
+=head2 group_by EMPTY|HASH|ARRAY_OF_HASHES
Groups the search results by column(s) and/or function(s) on column(s).
@@ -1133,20 +1133,23 @@
Join instructs Jifty::DBI::Collection to join two tables.
-The standard form takes a param hash with keys alias1, column1, alias2
-and column2. alias1 and alias2 are column aliases obtained from
-$self->new_alias or a $self->limit. column1 and column2 are the columns
-in alias1 and alias2 that should be linked, respectively. For this
+The standard form takes a param hash with keys C<alias1>, C<column1>, C<alias2>
+and C<column2>. C<alias1> and C<alias2> are column aliases obtained from
+$self->new_alias or a $self->limit. C<column1> and C<column2> are the columns
+in C<alias1> and C<alias2> that should be linked, respectively. For this
type of join, this method has no return value.
-Supplying the parameter type => 'left' causes Join to preform a left
-join. in this case, it takes alias1, column1, table2 and
-column2. Because of the way that left joins work, this method needs a
+Supplying the parameter C<type> => 'left' causes Join to preform a left
+join. in this case, it takes C<alias1>, C<column1>, C<table2> and
+C<column2>. Because of the way that left joins work, this method needs a
table for the second column rather than merely an alias. For this type
of join, it will return the alias generated by the join.
-Instead of alias1/column1, it's possible to specify expression, to join
-alias2/table2 on an arbitrary expression.
+The parameter C<operator> defaults C<=>, but you can specity other
+operators to join with.
+
+Instead of C<alias1>/C<column1>, it's possible to specify expression, to join
+C<alias2>/C<table2> on an arbitrary expression.
=cut
Modified: Jifty-DBI/trunk/lib/Jifty/DBI/Handle.pm
==============================================================================
--- Jifty-DBI/trunk/lib/Jifty/DBI/Handle.pm (original)
+++ Jifty-DBI/trunk/lib/Jifty/DBI/Handle.pm Wed Dec 21 19:46:03 2005
@@ -754,8 +754,8 @@
=head2 join { Paramhash }
-Takes a paramhash of everything Searchbuildler::Record does plus a
-parameter called 'collection' that contains a ref to a
+Takes a paramhash of everything Jifty::DBI::Collection's C<join> method
+takes, plus a parameter called C<collection> that contains a ref to a
L<Jifty::DBI::Collection> object'.
This performs the join.
@@ -775,6 +775,7 @@
column2 => undef,
alias2 => undef,
expression => undef,
+ operator => '=',
@_
);
@@ -867,7 +868,7 @@
= $args{'alias1'};
$args{'collection'}->{'leftjoins'}{"$alias"}{'criteria'}
{ 'criterion' . $args{'collection'}->{'criteria_count'}++ }
- = " $alias.$args{'column2'} = $criterion";
+ = " $criterion $args{'operator'} $alias.$args{'column2'}";
return ($alias);
}
@@ -883,6 +884,7 @@
table2 => undef,
column2 => undef,
alias2 => undef,
+ operator => '=',
@_
);
@@ -895,7 +897,7 @@
= " LEFT JOIN $args{'table2'} $alias ";
$sb->{'leftjoins'}{"$alias"}{'criteria'}{'base_criterion'}
- = " $args{'alias1'}.$args{'column1'} = $alias.$args{'column2'}";
+ = " $args{'alias1'}.$args{'column1'} $args{'operator'} $alias.$args{'column2'}";
return ($alias);
}
More information about the Rt-commit
mailing list