Changeset 269

Show
Ignore:
Timestamp:
11/30/07 09:15:19 (4 years ago)
Author:
ged
Message:

- the columns created by ManyToOne relationships create an index by default,

but this is only a default now instead of an hardcoded value: it can be
disabled now (through column_kwargs). Suggestion by Jason R. Coombs.

- added example of GenericProperty in docstring

Location:
elixir/trunk/elixir
Files:
2 modified

Legend:

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

    r267 r269  
    126126    ''' 
    127127    Generic catch-all class to wrap an SQLAlchemy property. 
     128 
     129    .. sourcecode:: python 
     130 
     131        class OrderLine(Entity): 
     132            quantity = Field(Float) 
     133            unit_price = Field(Numeric) 
     134            price = GenericProperty(lambda c: column_property( 
     135                             (c.quantity * c.unit_price).label('price'))) 
    128136    ''' 
    129137     
  • elixir/trunk/elixir/relationships.py

    r267 r269  
    477477        if 'primary_key' in kwargs: 
    478478            self.column_kwargs['primary_key'] = kwargs.pop('primary_key') 
     479        # by default, columns created will have an index. 
     480        self.column_kwargs.setdefault('index', True) 
    479481 
    480482        self.constraint_kwargs = kwargs.pop('constraint_kwargs', {}) 
     
    553555                # we can't add the column to the table directly as the table 
    554556                # might not be created yet. 
    555                 col = Column(colname, pk_col.type, index=True, 
    556                              **self.column_kwargs) 
     557                col = Column(colname, pk_col.type, **self.column_kwargs) 
    557558                source_desc.add_column(col) 
    558559