Fixing bug in PostgreSql when we use both limit & order in hasMany relations.

Mentioned in #1128