-
-
Notifications
You must be signed in to change notification settings - Fork 306
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
Support for collating function (sequence)? #767
Comments
Ok you've described the problem and what solution do you offer? How would you solve this issue with raw SQLite? Why don't you use custom collations instead of built-in? |
With raw SQLite I'd register custom collating function So, I think that SQLite-ORM should provide a wrapper for |
there is custom collation support. Just call |
OOPS, I must have mis-read the source code. I'm sorry. Any hint on how to specify the Thanks. |
auto rows = storage.select(&User::name, where(is_equal(&User::name, "Mercury").collate("ototo"))); |
Thank you! Out of curiosity, why The later seem to be more consistent with |
@zingchen several reasons:
If you want I can add strong typed API just like user defined functions have |
Please please do it. As |
Probably I did not understand you quite right. Do you mean that custom collation feature must have a strong typed API just like user defined functions feature has to eliminate the opportunity of typing collation name as string at many places? Like that: struct MyUnicodeCollation {
int operator()(int leftLength, const void *lhs, int rightLength, const void *rhs) const {
// cute comparison code here..
}
static std::string_view name() {
return "MY_UNICODE_COLLATION";
}
};
storage.create_collation<MyUnicodeCollation>();
auto rows = storage.select(&User::name, where(is_equal(&User::name, "Mercury").collate<MyUnicodeCollation>())); ? |
Yes. The syntax |
Ok I'll add it to the TODO list |
Thank you very much! |
You are welcome! https://github.com/fnc12/sqlite_orm/blob/dev/TODO.md please review the latest line in the list. Is the issue actual? |
Not so actual, compared to other items in the list. I can live with Some years ago, a student, who took an intro Ada course from me, told me that he prefers C++ to Ada because |
Cool story! |
@zingchen merged. Please check it out |
GCC encountered errors trying to compile the example
|
It works flawlessly now. (A variation of
Thank you very much. |
@zingchen you are welcome! |
The current version (v1.6) represents collating functions as an enum of 3 values:
binary
,nocase
andrtrim
, which corresponds to the 3 pre-built collating functions (also known as collating sequences in SQlite terminology). For many languages, the pre-built collating functions don't work.Let's consider for example Czech. Two Czech words are compared lexicographically, i.e. letter-by-letter. However, the letter ch (pronounced kh) is represented as a sequence of two characters (Unicode codepoints) c and h, and takes place between h and i in the Latin alphabet. Thus Christina (Czech version of Christine, Khristina) is an eight-letter word, and takes place after Hana and before Klara.
Another example is Vietnamese. A diacriticized letter, e.g. é, ế, is represented as either a single pre-composed character or a sequence of two characters, the un-diacriticized letter (e, ê) followed by the diacritical mark. (Note that ê may be considered diacriticized letter in other contexts.) Diacritical marks represent tone of words. Every word has zero or one diacritical mark. For comparison between two words, the words are first translated into un-diacriticized form, possibly with extra traling spaces so as they have the same length, followed by the diacritical mark. The two words, in translated form, are then compared lexicographically. (In other words, a diacritical mark is always compared against a diacritical mark and such comparison takes place if and only if the un-diacriticized version of the words equal.)
The text was updated successfully, but these errors were encountered: