Skip to content

Conversation

@iequidoo
Copy link
Collaborator

@iequidoo iequidoo commented Dec 1, 2025

This makes Contact::get_all() and Chatlist::try_load() case-insensitive for non-ASCII chat and contact names as well. The same approach as in f6f4ccc "feat: Case-insensitive search for non-ASCII messages (#5052)" is used: chats.name_normalized and contacts.name_normalized colums are added which store lowercased/normalized names (for a contact, if the name is unset, it's a normalized authname). If a normalized name is the same as the chat/contact name, it's not stored to reduce the db size. A db migration is added for 10000 random chats and the same number of the most recently seen contacts, for users it will probably migrate all chats/contacts and for bots which may have more data it's not important.

Fix #7477

@iequidoo iequidoo requested review from link2xt and r10s December 1, 2025 00:54
Copy link
Collaborator

@link2xt link2xt left a comment

Choose a reason for hiding this comment

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

Looks good, if it was tested on a real database with many chats and contacts then can be merged.

{
let (id, name) = res?;
if let Some(name_normalized) = normalize_text(&name) {
stmt.execute((name_normalized, id))?;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this run successfully on a real database? I am not sure about stepping over SELECT statement from a table and updating the same table in the same loop. Should probably be fine as long as you don't modify the columns that affect SELECT result or its order, but have not found if it is guaranteed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, probably should always work as it just fills a new column, at least my db migrated successfully and the search works as expected

…7477)

This makes `Contact::get_all()` and `Chatlist::try_load()` case-insensitive for non-ASCII chat and
contact names as well. The same approach as in f6f4ccc "feat:
Case-insensitive search for non-ASCII messages (#5052)" is used: `chats.name_normalized` and
`contacts.name_normalized` colums are added which store lowercased/normalized names (for a contact,
if the name is unset, it's a normalized authname). If a normalized name is the same as the
chat/contact name, it's not stored to reduce the db size. A db migration is added for 10000 random
chats and the same number of the most recently seen contacts, for users it will probably migrate all
chats/contacts and for bots which may have more data it's not important.
@iequidoo iequidoo force-pushed the iequidoo/case-insensitive-name-search branch from a70c4d5 to cd444d2 Compare December 5, 2025 07:56
@iequidoo iequidoo merged commit dea1b41 into main Dec 5, 2025
30 checks passed
@iequidoo iequidoo deleted the iequidoo/case-insensitive-name-search branch December 5, 2025 08:11
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.

get_chatlist and get_contacts are not case insensitive outside ASCII

3 participants