[Rt-commit] r6524 - in rt/branches/3.7-EXPERIMENTAL: .
ruz at bestpractical.com
ruz at bestpractical.com
Sun Nov 26 17:45:55 EST 2006
Author: ruz
Date: Sun Nov 26 17:45:55 2006
New Revision: 6524
Modified:
rt/branches/3.7-EXPERIMENTAL/ (props changed)
rt/branches/3.7-EXPERIMENTAL/lib/RT/Record.pm
Log:
r4181 at cubic-pc: cubic | 2006-11-27 01:49:44 +0300
r3514 at cubic-pc: cubic | 2006-06-29 06:56:42 +0400
RT::Record::LoadByCols
* don't create local copy of arguments unles DB is case sensetive
* even if it's sesetive create only one copy, change inplace
Other
* don't shift unused vars from @_
Modified: rt/branches/3.7-EXPERIMENTAL/lib/RT/Record.pm
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/lib/RT/Record.pm (original)
+++ rt/branches/3.7-EXPERIMENTAL/lib/RT/Record.pm Sun Nov 26 17:45:55 2006
@@ -99,10 +99,7 @@
=cut
-sub _PrimaryKeys {
- my $self = shift;
- return ( ['id'] );
-}
+sub _PrimaryKeys { return ['id'] }
# }}}
@@ -251,10 +248,7 @@
# {{{ sub _Handle
-sub _Handle {
- my $self = shift;
- return ($RT::Handle);
-}
+sub _Handle { return $RT::Handle }
# }}}
@@ -358,40 +352,29 @@
sub LoadByCols {
my $self = shift;
- my %hash = (@_);
# We don't want to hang onto this
delete $self->{'attributes'};
+ return $self->SUPER::LoadByCols( @_ ) unless $self->_Handle->CaseSensitive;
+
# If this database is case sensitive we need to uncase objects for
# explicit loading
- if ( $self->_Handle->CaseSensitive ) {
- my %newhash;
- foreach my $key ( keys %hash ) {
-
- # If we've been passed an empty value, we can't do the lookup.
- # We don't need to explicitly downcase integers or an id.
- if ( $key =~ '^id$'
- || !defined( $hash{$key} )
- || $hash{$key} =~ /^\d+$/
- )
- {
- $newhash{$key} = $hash{$key};
- }
- else {
- my ($op, $val, $func);
- ($key, $op, $val, $func) = $self->_Handle->_MakeClauseCaseInsensitive($key, '=', $hash{$key});
- $newhash{$key}->{operator} = $op;
- $newhash{$key}->{value} = $val;
- $newhash{$key}->{function} = $func;
- }
- }
+ my %hash = (@_);
+ foreach my $key ( keys %hash ) {
- # We've clobbered everything we care about. bash the old hash
- # and replace it with the new hash
- %hash = %newhash;
+ # If we've been passed an empty value, we can't do the lookup.
+ # We don't need to explicitly downcase integers or an id.
+ if ( $key ne 'id' && defined $hash{ $key } && $hash{ $key } !~ /^\d+$/ ) {
+ my ($op, $val, $func);
+ ($key, $op, $val, $func) =
+ $self->_Handle->_MakeClauseCaseInsensitive( $key, '=', delete $hash{ $key } );
+ $hash{$key}->{operator} = $op;
+ $hash{$key}->{value} = $val;
+ $hash{$key}->{function} = $func;
+ }
}
- $self->SUPER::LoadByCols(%hash);
+ return $self->SUPER::LoadByCols( %hash );
}
# }}}
More information about the Rt-commit
mailing list