Opened 6 years ago

Closed 6 years ago

#2140 closed defect (fixed)

Hql.sharedTo() generates incorrect HQL

Reported by: Nicklas Nordborg Owned by: everyone
Priority: major Milestone: BASE 3.13.1
Component: core Version:
Keywords: Cc:

Description

The Hql.sharedTo() method is used to restrict items returned by a query based on which users/groups/projects they are shared to. When this method is used and only the projects parameter is user it generates an incorrect query which causes an exception:

org.hibernate.hql.internal.ast.QuerySyntaxException:
  unexpected token: OR near line 1, column 87 
    [ SELECT bs FROM net.sf.basedb.core.data.BioSourceData bs 
      WHERE (bs.name = :name) AND 
      ( OR (bs.projectKey IN (select pk.id from      <<< Extra "OR"  
         net.sf.basedb.core.data.ProjectData prj 
         JOIN prj.projectKeys pk where (prj.id = 2312857)))
       )
    ]

The problem is the OR operator on the line that is marked above. It should not be inserted if both the users and groups parameters are null.

Change History (1)

comment:1 by Nicklas Nordborg, 6 years ago

Resolution: fixed
Status: newclosed

(In [7550]) Fixes #2140: Hql.sharedTo() generates incorrect HQL

Note: See TracTickets for help on using tickets.