fix: "fetch from" was broken on SQLite (#35774)
SQLite (like PostgreSQL) doesn't support `INNER JOIN` within `UPDATE` We can use the psql fallback we anyway had. Signed-off-by: Akhil Narang <me@akhilnarang.dev>
This commit is contained in:
parent
6ef39f3253
commit
4c58eba58b
1 changed files with 13 additions and 13 deletions
|
|
@ -362,19 +362,7 @@ class DocType(Document):
|
|||
continue # Invalid expression
|
||||
link_df = new_meta.get_field(link_fieldname)
|
||||
|
||||
if frappe.db.db_type == "postgres":
|
||||
update_query = """
|
||||
UPDATE `tab{doctype}`
|
||||
SET `{fieldname}` = source.`{source_fieldname}`
|
||||
FROM `tab{link_doctype}` as source
|
||||
WHERE `{link_fieldname}` = source.name
|
||||
"""
|
||||
if df.not_nullable:
|
||||
update_query += "AND `{fieldname}`=''"
|
||||
else:
|
||||
update_query += "AND ifnull(`{fieldname}`, '')=''"
|
||||
|
||||
else:
|
||||
if frappe.db.db_type == "mariadb":
|
||||
update_query = """
|
||||
UPDATE `tab{doctype}` as target
|
||||
INNER JOIN `tab{link_doctype}` as source
|
||||
|
|
@ -386,6 +374,18 @@ class DocType(Document):
|
|||
else:
|
||||
update_query += "WHERE ifnull(`target`.`{fieldname}`, '')=''"
|
||||
|
||||
else:
|
||||
update_query = """
|
||||
UPDATE `tab{doctype}`
|
||||
SET `{fieldname}` = source.`{source_fieldname}`
|
||||
FROM `tab{link_doctype}` as source
|
||||
WHERE `{link_fieldname}` = source.name
|
||||
"""
|
||||
if df.not_nullable:
|
||||
update_query += "AND `{fieldname}`=''"
|
||||
else:
|
||||
update_query += "AND ifnull(`{fieldname}`, '')=''"
|
||||
|
||||
self.flags.update_fields_to_fetch_queries.append(
|
||||
update_query.format(
|
||||
link_doctype=link_df.options,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue