Changeset 240

Show
Ignore:
Timestamp:
10/23/07 18:20:28 (6 years ago)
Author:
ged
Message:

- Added the possibility to give a custom name for ManyToOne constraints

(patch from and closes ticket #16)

Location:
elixir/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • elixir/trunk/CHANGES

    r238 r240  
    6161  mapper option so that it can actually be used. This allows to have entities 
    6262  without any primary key defined at the table level. 
     63- Added the possibility to give a custom name for ManyToOne constraints 
     64  (patch from and closes ticket #16) 
    6365- Dropped support for the old threadlocal SA extension (which doesn't even exist 
    6466  anymore in SA 0.4) 
  • elixir/trunk/elixir/relationships.py

    r236 r240  
    570570 
    571571                # build up the primary join. This is needed when you have  
    572                 # several belongs_to relations between two objects 
     572                # several belongs_to relationships between two objects 
    573573                self.primaryjoin_clauses.append(col == pk_col) 
    574574             
    575             # In some databases (at lease MySQL) the constraint name needs to  
    576             # be unique for the whole database, instead of per table. 
    577             fk_name = "%s_%s_fk" % (source_desc.tablename,  
    578                                     '_'.join(fk_colnames)) 
     575            if 'name' not in self.constraint_kwargs: 
     576                # In some databases (at least MySQL) the constraint name needs 
     577                # to be unique for the whole database, instead of per table. 
     578                fk_name = "%s_%s_fk" % (source_desc.tablename,  
     579                                        '_'.join(fk_colnames)) 
     580                self.constraint_kwargs['name'] = fk_name 
     581                 
    579582            source_desc.add_constraint( 
    580                 ForeignKeyConstraint(fk_colnames, fk_refcols, name=fk_name, 
     583                ForeignKeyConstraint(fk_colnames, fk_refcols, 
    581584                                     **self.constraint_kwargs)) 
    582585