Changeset 29639 for lang

Show
Ignore:
Timestamp:
02/06/09 16:37:59 (5 years ago)
Author:
yappo
Message:

add deflate in lookup/lookup_multi

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/Data-Model/trunk/lib/Data/Model.pm

    r29594 r29639  
    157157    $id = [ $id ] unless ref($id) eq 'ARRAY'; 
    158158 
     159    # deflating 
     160    my $id_hash = $schema->get_columns_hash_by_key_array_and_hash(+{}, $id); 
     161    $schema->deflate($id_hash); 
     162    $id = $schema->get_key_array_by_hash( $id_hash ); 
     163 
    159164    Carp::confess 'The number of key is wrong' 
    160165            unless scalar(@{ $id }) == scalar(@{ $schema->key }); 
     
    177182    return unless $schema; 
    178183 
    179     my @id_list = map { 
    180         ref($_) eq 'ARRAY' ? $_ : [ $_ ] 
    181     } ref($ids) eq 'ARRAY' ? @{ $ids } : ( $ids ); 
    182  
     184    $ids = [ $ids ] unless ref($ids) eq 'ARRAY'; 
    183185    my $id_size = scalar(@{ $schema->key }); 
    184     for my $id (@id_list) { 
     186    my @id_list; 
     187    for my $id (@{ $ids }) { 
     188        $id = [ $id ] unless ref($id) eq 'ARRAY'; 
     189 
    185190        Carp::confess 'The number of key is wrong' 
    186191                unless scalar(@{ $id }) == $id_size; 
     192 
     193        # deflating 
     194        my $id_hash = $schema->get_columns_hash_by_key_array_and_hash(+{}, $id); 
     195        $schema->deflate($id_hash); 
     196        $id = $schema->get_key_array_by_hash( $id_hash ); 
     197 
     198        push @id_list, $id; 
    187199    } 
    188200