Fix #5739 Activity feed bug for tables with similar name (#5760)

This commit is contained in:
Vivek Ratnavel Subramanian 2022-06-29 16:27:43 -07:00 committed by GitHub
parent c4bac17b83
commit df704fb566
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -679,7 +679,8 @@ public interface CollectionDAO {
@SqlQuery(
"SELECT json FROM thread_entity WHERE updatedAt > :before AND resolved = :resolved AND (:type IS NULL OR type = :type) AND "
+ "id in (SELECT fromFQN FROM field_relationship WHERE "
+ "toFQN LIKE CONCAT(:fqnPrefix, '%') AND fromType='THREAD' AND toType LIKE CONCAT(:toType, '%') AND relation= :relation) "
+ "(toFQN LIKE CONCAT(:fqnPrefix, '.%') OR toFQN=:fqnPrefix) AND fromType='THREAD' AND "
+ "(toType LIKE CONCAT(:toType, '.%') OR toType=:toType) AND relation= :relation) "
+ "ORDER BY updatedAt DESC "
+ "LIMIT :limit")
List<String> listThreadsByEntityLinkBefore(
@ -695,7 +696,8 @@ public interface CollectionDAO {
"SELECT json FROM thread_entity WHERE updatedAt < :after AND resolved = :resolved AND "
+ "(:type IS NULL OR type = :type) AND "
+ "id in (SELECT fromFQN FROM field_relationship WHERE "
+ "toFQN LIKE CONCAT(:fqnPrefix, '%') AND fromType='THREAD' AND toType LIKE CONCAT(:toType, '%') AND relation= :relation) "
+ "(toFQN LIKE CONCAT(:fqnPrefix, '.%') OR toFQN=:fqnPrefix) AND fromType='THREAD' AND "
+ "(toType LIKE CONCAT(:toType, '.%') OR toType=:toType) AND relation= :relation) "
+ "ORDER BY updatedAt DESC "
+ "LIMIT :limit")
List<String> listThreadsByEntityLinkAfter(
@ -711,7 +713,8 @@ public interface CollectionDAO {
"SELECT count(id) FROM thread_entity WHERE resolved = :resolved AND "
+ "(:type IS NULL OR type = :type) AND "
+ "id in (SELECT fromFQN FROM field_relationship WHERE "
+ "toFQN LIKE CONCAT(:fqnPrefix, '%') AND fromType='THREAD' AND toType LIKE CONCAT(:toType, '%') AND relation= :relation)")
+ "(toFQN LIKE CONCAT(:fqnPrefix, '.%') OR toFQN=:fqnPrefix) AND fromType='THREAD' AND "
+ "(toType LIKE CONCAT(:toType, '.%') OR toType=:toType) AND relation= :relation)")
int listCountThreadsByEntityLink(
@Bind("fqnPrefix") String fqnPrefix,
@Bind("toType") String toType,
@ -727,7 +730,8 @@ public interface CollectionDAO {
@SqlQuery(
"SELECT entityLink, COUNT(id) count FROM field_relationship fr INNER JOIN thread_entity te ON fr.fromFQN=te.id "
+ "WHERE fr.toFQN LIKE CONCAT(:fqnPrefix, '%') AND fr.toType like concat(:toType, '%') AND fr.fromType = :fromType "
+ "WHERE (fr.toFQN LIKE CONCAT(:fqnPrefix, '.%') OR fr.toFQN=:fqnPrefix) AND "
+ "(fr.toType like concat(:toType, '.%') OR fr.toType=:toType)AND fr.fromType = :fromType "
+ "AND fr.relation = :relation AND te.resolved= :isResolved AND (:type IS NULL OR te.type = :type) "
+ "GROUP BY entityLink")
@RegisterRowMapper(CountFieldMapper.class)