[Jifty-commit] r6671 - Jifty-DBI/branches/tisql/lib/Jifty/DBI
Jifty commits
jifty-commit at lists.jifty.org
Wed Mar 18 22:27:33 EDT 2009
Author: ruz
Date: Wed Mar 18 22:27:33 2009
New Revision: 6671
Modified:
Jifty-DBI/branches/tisql/lib/Jifty/DBI/Tisql.pm
Log:
* implement proper overloading for JDBI::Tisql::Column
Modified: Jifty-DBI/branches/tisql/lib/Jifty/DBI/Tisql.pm
==============================================================================
--- Jifty-DBI/branches/tisql/lib/Jifty/DBI/Tisql.pm (original)
+++ Jifty-DBI/branches/tisql/lib/Jifty/DBI/Tisql.pm Wed Mar 18 22:27:33 2009
@@ -664,6 +664,8 @@
"|" => "bit_or_op",
"&=" => "bit_assign_and_op",
"|=" => "bit_assign_or_op",
+
+ fallback => 1,
;
use Scalar::Util qw(blessed);
@@ -777,43 +779,36 @@
return $self->new( %res );
}
-sub bit_and_op {
- return (shift)->bit_op( @_, 'AND');
-}
-
-sub bit_or_op {
- return (shift)->bit_op( @_, 'OR');
-}
-
+sub bit_and_op { return (shift)->bit_op( @_, 'AND'); }
+sub bit_or_op { return (shift)->bit_op( @_, 'OR'); }
sub bit_op {
my ($self, $other, $invert, $op) = @_;
- die "'$other' is not a query condition"
- unless blessed $other && $other->isa(ref($self));
- my $res = $invert
- ? [ $other, $op, $self->{'tree'} ]
- : [ $self->{'tree'}, $op, $other ];
- return $self->new( tree => $res );
-}
-sub bit_assign_and_op {
- return (shift)->bit_assign_op( @_, 'AND');
-}
+ die "$other is not a query condition" if $invert;
-sub bit_assign_or_op {
- return (shift)->bit_assign_op( @_, 'OR');
+ die "'$other' is not a query condition"
+ unless blessed $other
+ && ( $other->isa('Jifty::DBI::Tisql::Tree')
+ || $other->isa('Jifty::DBI::Tisql::Condition')
+ );
+
+ return Jifty::DBI::Tisql::Tree->new( $self, $op, $other );
}
+sub bit_assign_and_op { return (shift)->bit_assign_op( @_, 'AND') }
+sub bit_assign_or_op { return (shift)->bit_assign_op( @_, 'OR') }
sub bit_assign_op {
my ($self, $other, $invert, $op) = @_;
+
+ die "$other is not a query condition" if $invert;
+
die "'$other' is not a query condition"
- unless blessed $other && $other->isa(ref($self));
+ unless blessed $other
+ && ( $other->isa('Jifty::DBI::Tisql::Tree')
+ || $other->isa('Jifty::DBI::Tisql::Condition')
+ );
- if ( $invert ) {
- $other->{'tree'} = [ $other->{'tree'}, $op, $self->{'tree'} ];
- } else {
- $self->{'tree'} = [ $self->{'tree'}, $op, $other->{'tree'} ];
- }
- return $self;
+ return $self = Jifty::DBI::Tisql::Tree->new( $self, $op, $other );
}
package Jifty::DBI::Tisql::Column;
More information about the Jifty-commit
mailing list