Hi,

I found a bug with ManyToMany when Entities are using a schema. The 
intermediate table as well as the foreign key constraints didn't respect 
that.

I created the attached patch, now things work for me.

Creating a ticket in trac wasn't possible for me & I didn't found a way to 
register.

 And I also tried creating a test. I've let the tests_m2m run, they work - but 
because of the lack of schema-support and me not finding a way to let tests 
run against a postgres, I wasn't able to do so.

Regards,

Diez B. Roggisch

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"SQLElixir" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlelixir?hl=en
-~----------~----~----~----~------~----~------~--~---

--- elixir-0.5.2/elixir/relationships.py	2008-06-19 11:50:14.000000000 +0200
+++ elixir-0.5.2-unmodified/elixir/relationships.py	2008-06-19 11:44:14.000000000 +0200
@@ -704,11 +704,6 @@
         e1_desc = self.entity._descriptor
         e2_desc = self.target._descriptor
 
-        e1_schema = e1_desc.table_options.get('schema', None)
-        e2_schema = e2_desc.table_options.get('schema', None)
-        assert  e1_schema == e2_schema, "Schema %r for entity %s differs from schema %r of entity %s" % (e1_schema, e1_desc.entity.__name__, e2_schema, e2_desc.entity.__name__)
-
-
         # First, we compute the name of the table. Note that some of the
         # intermediary variables are reused later for the constraint
         # names.
@@ -783,10 +778,7 @@
 
                     # Build the list of columns the foreign key will point
                     # to.
-                    temp = desc.tablename
-                    if e1_schema is not None:
-                        temp = e1_schema + "." + temp
-                    fk_refcols.append(temp + '.' + pk_col.key)
+                    fk_refcols.append(desc.tablename + '.' + pk_col.key)
 
                     # Build join clauses (in case we have a self-ref)
                     if self.entity is self.target:
@@ -803,7 +795,7 @@
             args = columns + constraints
 
             self.secondary_table = Table(tablename, e1_desc.metadata,
-                                         schema=e1_schema, *args)
+                                         *args)
 
     def _reflect_table(self, tablename):
         if not self.target._descriptor.autoload:

Reply via email to