diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-02-14 02:15:47 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-02-14 02:15:47 +0000 |
commit | d856a373fec3f043013d9dc3cfe048326b35c565 (patch) | |
tree | 4e883c948fa55a4d1a472a2aff86145d5619d4cb /lib/sqlalchemy/mapping/properties.py | |
parent | fa11bcd6720548b0e845623f8c3b4c93b3a47939 (diff) | |
download | sqlalchemy-d856a373fec3f043013d9dc3cfe048326b35c565.tar.gz |
the list-based foreign key doenst seem to work quite right, rolling it back
Diffstat (limited to 'lib/sqlalchemy/mapping/properties.py')
-rw-r--r-- | lib/sqlalchemy/mapping/properties.py | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/lib/sqlalchemy/mapping/properties.py b/lib/sqlalchemy/mapping/properties.py index 9c92f42bf..3a319703d 100644 --- a/lib/sqlalchemy/mapping/properties.py +++ b/lib/sqlalchemy/mapping/properties.py @@ -116,13 +116,9 @@ class PropertyLoader(MapperProperty): # a list of columns representing "the other side" # of the relationship - self.foreignkey = util.to_set(foreignkey) - - # foreign table is then just the table represented - # by the foreignkey - for c in self.foreignkey: - self.foreigntable = c.table - break + self.foreignkey = foreignkey #util.to_set(foreignkey) + if foreignkey: + self.foreigntable = foreignkey.table else: self.foreigntable = None @@ -177,7 +173,7 @@ class PropertyLoader(MapperProperty): # if the foreign key wasnt specified and theres no assocaition table, try to figure # out who is dependent on who. we dont need all the foreign keys represented in the join, # just one of them. - if self.foreignkey.empty() and self.secondaryjoin is None: + if self.foreignkey is None and self.secondaryjoin is None: # else we usually will have a one-to-many where the secondary depends on the primary # but its possible that its reversed self._find_dependent() @@ -222,9 +218,8 @@ class PropertyLoader(MapperProperty): def _get_direction(self): # print self.key, repr(self.parent.table.name), repr(self.parent.primarytable.name), repr(self.foreignkey.table.name) if self.parent.table is self.target: - for col in self.foreignkey: - if col.primary_key: - return PropertyLoader.MANYTOONE + if self.foreignkey.primary_key: + return PropertyLoader.MANYTOONE else: return PropertyLoader.ONETOMANY elif self.secondaryjoin is not None: @@ -250,12 +245,12 @@ class PropertyLoader(MapperProperty): if dependent[0] is binary.left.table: raise "bidirectional dependency not supported...specify foreignkey" dependent[0] = binary.right.table - self.foreignkey.append(binary.right) + self.foreignkey= binary.right elif isinstance(binary.right, schema.Column) and binary.right.primary_key: if dependent[0] is binary.right.table: raise "bidirectional dependency not supported...specify foreignkey" dependent[0] = binary.left.table - self.foreignkey.append(binary.left) + self.foreignkey = binary.left visitor = BinaryVisitor(foo) self.primaryjoin.accept_visitor(visitor) if dependent[0] is None: @@ -699,12 +694,12 @@ def create_lazy_clause(table, primaryjoin, secondaryjoin, foreignkey): binds = {} def visit_binary(binary): circular = isinstance(binary.left, schema.Column) and isinstance(binary.right, schema.Column) and binary.left.table is binary.right.table - if isinstance(binary.left, schema.Column) and ((not circular and binary.left.table is table) or (circular and binary.right in foreignkey)): + if isinstance(binary.left, schema.Column) and ((not circular and binary.left.table is table) or (circular and binary.right is foreignkey)): binary.left = binds.setdefault(binary.left, sql.BindParamClause(binary.right.table.name + "_" + binary.right.name, None, shortname = binary.left.name)) binary.swap() - if isinstance(binary.right, schema.Column) and ((not circular and binary.right.table is table) or (circular and binary.left in foreignkey)): + if isinstance(binary.right, schema.Column) and ((not circular and binary.right.table is table) or (circular and binary.left is foreignkey)): binary.right = binds.setdefault(binary.right, sql.BindParamClause(binary.left.table.name + "_" + binary.left.name, None, shortname = binary.right.name)) |