roadmap icon indicating copy to clipboard operation
roadmap copied to clipboard

Strip Outer Spaces Of User Search String and Queried DB Fields

Open aaronskiba opened this issue 1 year ago • 0 comments

Changes proposed in this PR:

  • Addresses the following edge-case: https://github.com/DMPRoadmap/roadmap/pull/3407#issuecomment-2192201540
  • In addition to applying .squish to the user-inputted search term, .strip is applied as well. For example, if " x " was typed by the user, then a query would be made for "x".
  • Similarly, trim() is applied to the db values for for User.firstname and User.surname. For example, if the value for one of these fields was " x ", then it would be trimmed to "x".

Additional Notes:

  • There is still another edge-case. That is, it is possible for a User.firstname or User.lastname value to exist in the db having multiple spaces in-between non-space characters. In fact, there are two currently in the production db of DMP Assistant:

  • SELECT firstname, lastname
    FROM users
    WHERE trim(firstname) LIKE '%  %' -- Multiple consecutive spaces within string after applying trim
    OR trim(surname) LIKE '%  %';
    -------------------------------
    count: 2
    
  • It would be great to expand the concept of #3407 to other search bars within the app, but the following issue should probably be addressed first: https://github.com/DMPRoadmap/roadmap/issues/3432

aaronskiba avatar Jun 28 '24 17:06 aaronskiba