Skip to content
  • epriestley's avatar
    Select Ferret fulltext columns in results so fulltext queries work under UNION · b90e02be
    epriestley authored
    Summary:
    Ref T13091. In Differential, if you provide a query and "Sort by: Relevance", we build a query like this:
    
    ```
    ((SELECT revision.* FROM ... ORDER BY rank) UNION ALL (SELECT revision.* FROM ... ORDER BY rank)) ORDER BY rank
    ```
    
    The internal "ORDER BY rank" is technically redundant (probably?), but doesn't hurt anything, and makes construction easier.
    
    The problem is that the outer "ORDER BY rank" at the end, which attempts to order the results of the two parts of the UNION, can't actually order them, since `rank` wasn't selected.
    
    (The column isn't actually "rank", which //is// selected -- it's the document modified/created subcolumns, which are not.)
    
    To fix this, actually select the fulltext columns into the result set.
    
    Test Plan:
      - Ran a non-empty fulltext query in Differential with "Bucket: Required Action" selected so the UNION construction fired.
      - Ran normal queries in Maniphest and global search.
    
    Reviewers: amckinley
    
    Reviewed By: amckinley
    
    Maniphest Tasks: T13091
    
    Differential Revision: https://secure.phabricator.com/D20297
    b90e02be