[MERGE] ORM: fix result of queries using auto_join.
[MERGE] ORM: fix result of queries using auto_join.

It is possible to have multiple results linked to a same 'left-side' query, such as having a task with several unread messages. In this case, the query using the joins gives back as many lines as unread messages, because of the joins in the query.
To avoid using distinct or 'where exist' constructs, the results of the query is filtered while keeping the original order.
MarkusTeufelberger/openobject-server,gisce/openobject-server,MarkusTeufelberger/openobject-server,gisce/openobject-server,MarkusTeufelberger/openobject-server,splbio/openobject-server,splbio/openobject-server,splbio/openobject-server,gisce/openobject-server