Skip to content
This repository has been archived by the owner on Jun 20, 2022. It is now read-only.

Search with case insensitiveness #12

Merged
merged 1 commit into from
May 30, 2019
Merged

Search with case insensitiveness #12

merged 1 commit into from
May 30, 2019

Conversation

feugy
Copy link
Contributor

@feugy feugy commented May 29, 2019

What's in there?

As for #11, we would like so search for values regardless of their case.
This adds

  • a new caseInsensitive option to search() method (default behave as it used to).
  • documentation
  • changelog update (version 2 wasn't released yet)

Notes to reviewers

Writing

const op = caseInsensitive ? 'ILIKE' : 'LIKE'
if (who) sql.append(SQL` AND who_id ${op} ${exactMatch ? who : '%' + who + '%'}`)

Does not work, because op is treated as a parameter and escaped, leading to incorrect query (error is: syntax error at or near "$3")

Unfortunately, the .append() method of our SQLStatements object does not allow plain strings (as opposed to this library), leading to this convoluted syntax:

if (who) sql.append(SQL([` AND who_id ${op} `])).append(SQL`${exactMatch ? who : '%' + who + '%'}`)

@feugy feugy requested a review from ShogunPanda May 29, 2019 06:42
Copy link
Contributor

@ShogunPanda ShogunPanda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@feugy feugy merged commit f1c60a1 into master May 30, 2019
@feugy feugy deleted the case-insensitive branch May 30, 2019 03:40
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants