Merge pull request #34692 from ankush/global_search_update

fix: Update values on conflict in global search
This commit is contained in:
Ankush Menat 2025-11-14 11:06:02 +05:30 committed by GitHub
commit 5bbdff9018
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -219,9 +219,15 @@ def insert_values_for_multiple_docs(all_contents):
# ignoring duplicate keys for doctype_name
frappe.db.multisql(
{
"mariadb": """INSERT IGNORE INTO `__global_search`
"mariadb": """INSERT INTO `__global_search`
(doctype, name, content, published, title, route)
VALUES {} """.format(", ".join(batch_values)),
VALUES {}
ON DUPLICATE KEY UPDATE
content=VALUE(content),
published=VALUE(published),
title=VALUE(title),
route=VALUE(route)
""".format(", ".join(batch_values)),
"postgres": """INSERT INTO `__global_search`
(doctype, name, content, published, title, route)
VALUES {}
@ -422,6 +428,7 @@ def sync_value_in_queue(value):
frappe.cache.lpush("global_search_queue", json.dumps(value))
except redis.exceptions.ConnectionError:
# not connected, sync directly
assert not frappe.flags.in_test, "Should not fail silently in tests"
sync_value(value)