-
Notifications
You must be signed in to change notification settings - Fork 97
Custom collations #19
Comments
I have a problem with statements like
According to my readings this can be solved with a Custom Collation. I see that this issue was open almost 3 years ago, so I suppose it won't be done anytime soon. In the meantime, do you know of any workarounds? I found several solutions but nothing I can apply to this library for .NET Core. |
In version 2.0, we're moving to SQLitePCL.raw which makes it a lot easier to do. using (var connection = new SqliteConnection(connectionString))
{
connection.Open();
SQLitePCL.raw.sqlite3_create_collation(
connection.Handle,
"MY_NOCASE",
null,
(_, s1, s2) => string.Compare(s1, s2, StringComparison.OrdinalIgnoreCase));
// TODO: "SELECT 'Νίκος' = 'ΝΙΚΟΣ' COLLATE MY_NOCASE;"
} You can also do this with version 1.x, but you need to define your own P/Invoke of |
I think it would make sense to add a new method for this in SqliteConnection. The SQLitePCL.raw function for the creation has four parameters: the connection handle, the name of the collation, an object which can be passed into the collation and a special delegate of type So my proposal would be an function like this in |
See this comment for how System.Data.SQLite enables this. |
Yes, I like your design. This is my ideal usage: connection.CreateCollation(
"NOCASE",
(s1, s2) => string.Compare(s1, s2, StringComparison.OrdinalIgnoreCase)); We should discuss in #14 whether we want different methods for collations, scalar functions, and aggregates; or if we want to try and use overloads like System.Data.SQLite. |
I don't want to pollute this thread, I just want ot mention (for future reference) that the custom collation doesn't solve the issue after all. With the help of the revious posts, I managed to make a custom collation, and now
|
@AlexanderTaeschner I'm going to bring this to the team design meeting on Thursday. I don't expect much controversy on this one. Really, the only things to discuss are the method name and how the API relates to user-defined functions. |
I've added our design to the main description of the issue. |
SQLite allows you to define new collating sequences. We want to enable this by allowing calls like the following.
The definitions for the new API would be:
The text was updated successfully, but these errors were encountered: