Fix issue with reverse(many) for models with custom pk

- Also add test covering the issue
This commit is contained in:
Pelle Johnsen
2015-12-15 17:17:56 +01:00
parent 332fa44231
commit 906637ae8b
3 changed files with 89 additions and 1 deletions

View File

@@ -186,7 +186,7 @@ func (t *dbTables) getJoinSQL() (join string) {
table = jt.mi.table
switch {
case jt.fi.fieldType == RelManyToMany || jt.fi.reverse && jt.fi.reverseFieldInfo.fieldType == RelManyToMany:
case jt.fi.fieldType == RelManyToMany || jt.fi.fieldType == RelReverseMany || jt.fi.reverse && jt.fi.reverseFieldInfo.fieldType == RelManyToMany:
c1 = jt.fi.mi.fields.pk.column
for _, ffi := range jt.mi.fields.fieldsRel {
if jt.fi.mi == ffi.relModelInfo {