Changeset 414

Show
Ignore:
Timestamp:
10/31/08 11:20:33 (5 years ago)
Author:
ged
Message:

Allow "colname" argument to be specified in addition to "primaryjoin" argument
on M2O relationships of autoloaded entities. This is useless but harmless.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • elixir/trunk/elixir/relationships.py

    r413 r414  
    616616 
    617617        if source_desc.autoload: 
    618             #TODO: test if this works when colname is a list 
    619  
     618            #TODO: allow target_column to be used as an alternative to 
     619            # specifying primaryjoin, to be consistent with non-autoloaded 
     620            # tables 
    620621            if self.colname: 
    621                 self.primaryjoin_clauses = \ 
    622                     _get_join_clauses(self.entity.table, 
    623                                       self.colname, None, 
    624                                       self.target.table)[0] 
    625                 if not self.primaryjoin_clauses: 
    626                     raise Exception( 
    627                         "Couldn't find a foreign key constraint in table " 
    628                         "'%s' using the following columns: %s." 
    629                         % (self.entity.table.name, ', '.join(self.colname))) 
     622                if 'primaryjoin' not in self.kwargs: 
     623                    self.primaryjoin_clauses = \ 
     624                        _get_join_clauses(self.entity.table, 
     625                                          self.colname, None, 
     626                                          self.target.table)[0] 
     627                    if not self.primaryjoin_clauses: 
     628                        colnames = ', '.join(self.colname) 
     629                        raise Exception( 
     630                            "Couldn't find a foreign key constraint in table " 
     631                            "'%s' using the following columns: %s." 
     632                            % (self.entity.table.name, colnames)) 
    630633            if self.field: 
    631634                raise NotImplementedError(