Changeset 401

Show
Ignore:
Timestamp:
09/15/08 15:32:51 (5 years ago)
Author:
ged
Message:

- fixed bug with the new "schema" argument on ManyToMany relationships (I

introduced it in my modification of the original patch).

- added some more documentation on Relationships
- removed unused imports

Location:
elixir/trunk/elixir
Files:
3 modified

Legend:

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

    r383 r401  
    105105        has_field('name', String(50)) 
    106106''' 
    107 import sys 
    108  
    109107from sqlalchemy import Column 
    110108from sqlalchemy.orm import deferred, synonym 
  • elixir/trunk/elixir/options.py

    r400 r401  
    174174''' 
    175175 
    176 import sqlalchemy 
    177 import sqlalchemy.orm 
    178176from sqlalchemy import Integer, String 
    179177 
  • elixir/trunk/elixir/relationships.py

    r400 r401  
    6464| Option Name          | Description                                          | 
    6565+======================+======================================================+ 
    66 | ``colname``          | Specify a custom column name.                        | 
     66| ``colname``          | Specify a custom name for the foreign key column(s). | 
     67|                      | This argument accepts either a single string or a    | 
     68|                      | list of strings. The number of strings passed must   | 
     69|                      | match the number of primary key columns of the target| 
     70|                      | entity. If this argument is not used, the name of the| 
     71|                      | column(s) is generated with the pattern              | 
     72|                      | defined in options.FKCOL_NAMEFORMAT, which is, by    | 
     73|                      | default: "%(relname)s_%(key)s", where relname is the | 
     74|                      | name of the ManyToOne relationship, and 'key' is the | 
     75|                      | name (key) of the primary column in the target       | 
     76|                      | entity. That's with, in the above Pet/owner example, | 
     77|                      | the name of the column would be: "owner_id".         | 
    6778+----------------------+------------------------------------------------------+ 
    6879| ``required``         | Specify whether or not this field can be set to None | 
     
    124135+======================+======================================================+ 
    125136| ``field``            | Specify the previously-declared field to be used for | 
    126 |                      | the foreign key                                      | 
    127 |                      | column. Use of this parameter is mutually exclusive  | 
    128 |                      | with the colname and column_kwargs arguments.        | 
     137|                      | the foreign key column. Use of this parameter is     | 
     138|                      | mutually exclusive with the colname and column_kwargs| 
     139|                      | arguments.                                           | 
    129140+----------------------+------------------------------------------------------+ 
    130141 
     
    216227        articles = ManyToMany('Article') 
    217228 
    218 Behind the scene, the ``ManyToMany`` relationship will 
    219 automatically create an intermediate table to host its data. 
     229Behind the scene, the ``ManyToMany`` relationship will automatically create an 
     230intermediate table to host its data. 
    220231 
    221232Note that you don't necessarily need to define the inverse relationship.  In 
     
    237248|                    | can be used both when the tables needs to be created   | 
    238249|                    | and when the table is autoloaded/reflected from the    | 
    239 |                    | database.                                              | 
     250|                    | database. If this argument is not used, a name will be | 
     251|                    | automatically generated by Elixir depending on the name| 
     252|                    | of the tables of the two entities of the relationship, | 
     253|                    | the name of the relationship, and, if present, the name| 
     254|                    | of its inverse. Even though this argument is optional, | 
     255|                    | it is wise to use it if you are not sure what are the  | 
     256|                    | exact consequence of using a generated table name.     | 
    240257+--------------------+--------------------------------------------------------+ 
    241258| ``schema``         | Specify a custom schema for the intermediate table.    | 
     
    374391''' 
    375392 
    376 import sys 
    377393import warnings 
    378394 
     
    383399import options 
    384400from elixir.statements import ClassMutator 
    385 from elixir.fields import Field 
    386401from elixir.properties import Property 
    387 from elixir.entity import EntityDescriptor, EntityMeta, DEBUG 
     402from elixir.entity import EntityMeta, DEBUG 
    388403 
    389404__doc_all__ = [] 
     
    823838        e1_schema = e1_desc.table_options.get('schema', None) 
    824839        e2_schema = e2_desc.table_options.get('schema', None) 
    825         schema = (self.schema is not None) and schema or e1_schema 
     840        schema = (self.schema is not None) and self.schema or e1_schema 
    826841 
    827842        assert e1_schema == e2_schema or self.schema, \