diff --git a/core/db/index-create.sql b/core/db/index-create.sql index f499ecfe5741..493e7fa0d0c6 100644 --- a/core/db/index-create.sql +++ b/core/db/index-create.sql @@ -1,6 +1,7 @@ -- authorization: CREATE INDEX permission_service_method ON permission (service_method); CREATE INDEX profile_permission_permission_fk_profile_active ON profile_permission (permission_fk,profile,active); +CREATE INDEX user_permission_profile_user_fk_active_profile ON user_permission_profile (user_fk,active,profile); -- criteria: CREATE INDEX criterion_property_module_property ON criterion_property (module,property); diff --git a/core/db/schema-set-version.sql b/core/db/schema-set-version.sql index 6808ebb53fe1..a1483613e667 100644 --- a/core/db/schema-set-version.sql +++ b/core/db/schema-set-version.sql @@ -11,4 +11,4 @@ begin end $$ language plpgsql; -select set_database_version('010801040'); \ No newline at end of file +select set_database_version('010801050'); \ No newline at end of file diff --git a/core/db/schema-up-master.sql b/core/db/schema-up-master.sql index 1ced9ae484d8..04eccae12961 100644 --- a/core/db/schema-up-master.sql +++ b/core/db/schema-up-master.sql @@ -60,5 +60,13 @@ if get_database_version() < '010801040' then end if; +if get_database_version() < '010801050' then + + CREATE INDEX user_permission_profile_user_fk_active_profile ON user_permission_profile (user_fk,active,profile); + + perform set_database_version('010801050'); + +end if; + end $$; diff --git a/core/src/main/java/org/phoenixctms/ctsms/domain/VisitScheduleItemDaoImpl.java b/core/src/main/java/org/phoenixctms/ctsms/domain/VisitScheduleItemDaoImpl.java index 1ea6e51bf2e7..95a9b3f41e7d 100644 --- a/core/src/main/java/org/phoenixctms/ctsms/domain/VisitScheduleItemDaoImpl.java +++ b/core/src/main/java/org/phoenixctms/ctsms/domain/VisitScheduleItemDaoImpl.java @@ -172,7 +172,7 @@ private static LinkedHashMap applyExpandDateModeCriterions(o org.hibernate.Criteria stopTagValuesValueCriteria = stopTagValuesCriteria.createCriteria("value", CriteriaSpecification.LEFT_JOIN); // from the cross product, remove those with start+stop values of different probands. also include rows without existing stop tag values visitScheduleItemCriteria.add(CriteriaUtil.applyOr( - Restrictions.or(Restrictions.eqProperty("startTagValues.listEntry.id", "stopTagValues.listEntry.id"), Restrictions.isNull("stopTagValues.listEntry.id")), or)); + Restrictions.or(Restrictions.eqProperty("startTagValues.listEntry.id", "stopTagValues.listEntry.id"), Restrictions.isNull("stopTag.id")), or)); // narrow to particular proband, if given org.hibernate.Criteria startTagValuesListEntryCriteria = startTagValuesCriteria.createCriteria("listEntry", "startTagValuesListEntry", CriteriaSpecification.LEFT_JOIN); if (probandId != null) {