gregelenbaas / diesel-citext

Diesel support for citext extension
MIT License
11 stars 11 forks source link

Why is `to_lowercase` called? #2

Closed xtian closed 5 years ago

xtian commented 5 years ago

Before sending to postgres and after parsing from postgres, the text content is always passed through the Rust String to_lowercase method.

Why is this done? Isn't the point of the CITEXT type that the DB backend handles this?

gregelenbaas commented 5 years ago

CiString ,which is what CiText converts to, calls to_lowercase() when instantiated to not have to call to_lowercase when doing an equality check are when creating a hash key. I'm open to suggestions and/or PRs if something could be improved upon.

xtian commented 5 years ago

But why is CiString needed?

gregelenbaas commented 5 years ago

It's needed so that you can do case insensitive comparisons in rust. It easily converts to string if that's what you need,

xtian commented 5 years ago

Ok gotcha. It might be cool if there was a way to just use String as the Rust type instead of the wrapper if you don't need that functionality.

evgeni-nabokov commented 4 years ago

What is the point to lower the string in CiText? The point to have CiText in Postgres is to have strings that looks like a regular text, but internally compared insensitively. You effectively destroyed the mission of CiText.