Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'like' extension to Option[String] #2297

Closed
wants to merge 1 commit into from

Conversation

guersam
Copy link

@guersam guersam commented Nov 1, 2021

Supersedes #2039

Problem

  1. In large databases, string partial match on nullable strings are not uncommon. It would be more ergonomic to write field like "%abc%" than field.exists(_ like "%abc%").
  2. Furthermore, "like" extension sometimes causes syntax error In SQL Server as reported in Fix like to be used as condition to generate valid sql #2039

Solution

  • Add LikeOption(s1: Option[String]) extension similar to Like.
  • Make "like" expression a condition instead of a boolean

Checklist

  • Unit test all changes
  • Update README.md if applicable
  • Add [WIP] to the pull request title if it's work in progress
  • Squash commits that aren't meaningful changes
  • Run sbt scalariformFormat test:scalariformFormat to make sure that the source files are formatted

@getquill/maintainers

- Add 'like' extension to Option[String]
- Make like expr a condition instead of boolean
@guersam
Copy link
Author

guersam commented Nov 24, 2021

Rebased onto the current master.

@deusaquilus
Copy link
Collaborator

@guersam So #2039 looks totally right but I'm not sure about this. Can you do field.getOrNull like "%abc%". We also support that.

@guersam
Copy link
Author

guersam commented Feb 4, 2022

I'd like to avoid it because there are too many of them in my usecase, but I can bake the extension into my custom context anyway.

@guersam guersam closed this Feb 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants