mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-17 15:03:18 +00:00
Rewrote query for selecting distinct values scoped to comm/coll due to deficiency in Postgres
git-svn-id: http://scm.dspace.org/svn/repo/trunk@2663 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
@@ -1022,6 +1022,15 @@ public class BrowseDAOPostgres implements BrowseDAO
|
|||||||
// Then append the table
|
// Then append the table
|
||||||
queryBuf.append(" FROM ");
|
queryBuf.append(" FROM ");
|
||||||
queryBuf.append(table);
|
queryBuf.append(table);
|
||||||
|
if (containerTable != null && tableMap != null)
|
||||||
|
{
|
||||||
|
queryBuf.append(", (SELECT DISTINCT ").append(tableMap).append(".distinct_id ");
|
||||||
|
queryBuf.append(" FROM ");
|
||||||
|
buildFocusedSelectTables(queryBuf);
|
||||||
|
queryBuf.append(" WHERE ");
|
||||||
|
buildFocusedSelectClauses(queryBuf, params);
|
||||||
|
queryBuf.append(") mappings");
|
||||||
|
}
|
||||||
queryBuf.append(" ");
|
queryBuf.append(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1044,12 +1053,7 @@ public class BrowseDAOPostgres implements BrowseDAO
|
|||||||
if (containerIDField != null && containerID != -1 && containerTable != null)
|
if (containerIDField != null && containerID != -1 && containerTable != null)
|
||||||
{
|
{
|
||||||
buildWhereClauseOpInsert(queryBuf);
|
buildWhereClauseOpInsert(queryBuf);
|
||||||
|
queryBuf.append(" ").append(table).append(".id=mappings.distinct_id ");
|
||||||
queryBuf.append(" EXISTS (SELECT 1 FROM ");
|
|
||||||
buildFocusedSelectTables(queryBuf);
|
|
||||||
queryBuf.append(" WHERE ");
|
|
||||||
buildFocusedSelectClauses(queryBuf, params);
|
|
||||||
queryBuf.append(" AND distinct_id=" + table + ".id) ");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user