fix: global search index breaking on long titles

If you created a doc with a title longer than 140 characters, it's supposed to be truncated to 140.

However, the global search index would break for that doctype due to an error in the query.

The truncate was happening AFTER it was escaped, causing it to lose the closing quote mark which caused a SQL error and broke the index.
This commit is contained in:
Ben Knowles 2020-01-02 14:33:57 -06:00 committed by GitHub
parent 4ac83a0cc8
commit ecfc0714bc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -137,8 +137,8 @@ def rebuild_for_doctype(doctype):
"name": frappe.db.escape(doc.name),
"content": frappe.db.escape(' ||| '.join(content or '')),
"published": published,
"title": frappe.db.escape(title or '')[:int(frappe.db.VARCHAR_LEN)],
"route": frappe.db.escape(route or '')[:int(frappe.db.VARCHAR_LEN)]
"title": frappe.db.escape((title or '')[:int(frappe.db.VARCHAR_LEN)]),
"route": frappe.db.escape((route or '')[:int(frappe.db.VARCHAR_LEN)])
})
if all_contents:
insert_values_for_multiple_docs(all_contents)