id,summary,reporter,owner,description,type,status,priority,milestone,component,version,resolution,keywords,cc
996,No foreign keys on manytomany table without through,hvdklauw@…,andrew,"I just discovered south does not create foreignkey relations on ManyToMany definitions without through specification.

auth_group_permissions (no south) has ForeignKey definitions

Every South managed app with a ManyToMany without a through does not have the foreignkey's defined.

No index, no foreign key is horrible, the django orm generated double negative queries when you try to find  elements which only have items on the other side of the relations and thus return less results then then there actually are.

{{{
#!sql
SELECT ""producttypes_producttype"".""id"",
       ""producttypes_producttype"".""title"",
       ""producttypes_producttype"".""slug"",
       ""producttypes_producttype"".""vat_id"",
       ""producttypes_producttype"".""parent_id"",
       ""producttypes_producttype"".""slug_url"",
       ""producttypes_producttype"".""whole_title"",
       ""producttypes_producttype"".""lft"",
       ""producttypes_producttype"".""rght"",
       ""producttypes_producttype"".""tree_id"",
       ""producttypes_producttype"".""level""
FROM ""producttypes_producttype""
WHERE NOT ((""producttypes_producttype"".""id"" IN
                (SELECT U0.""id""
                 FROM ""producttypes_producttype"" U0
                 LEFT OUTER JOIN ""products_product_producttypes"" U1 ON (U0.""id"" = U1.""producttype_id"")
                 LEFT OUTER JOIN ""products_product"" U2 ON (U1.""product_id"" = U2.""id"")
                 WHERE (U2.""id"" IS NULL
                        AND U0.""id"" IS NOT NULL))
            AND ""producttypes_producttype"".""id"" IS NOT NULL
            AND ""producttypes_producttype"".""id"" IS NOT NULL))
ORDER BY ""producttypes_producttype"".""tree_id"" ASC, ""producttypes_producttype"".""lft"" ASC, ""producttypes_producttype"".""title"" ASC
}}}
",defect,closed,blocker,,migrations,0.7.3,worksforme,,hvdklauw@…
