Error: When building the “Participating” feed (or when a participator filter is used), clause_discussions_commented_by_user() materializes a Python list of discussion names and returns Discussion.name.isin(list). For users with no comments, this produced an empty IN clause (IN ()), which renders invalid SQL and causes MariaDB error 1064.
Suggested Solution (Worked fine for me):
def clause_discussions_commented_by_user(user):
Discussion = frappe.qb.DocType("GP Discussion")
commented_in = list(
- set(
- frappe.db.get_all(
- "GP Comment",
- fields=["reference_name"],
- filters={"reference_doctype": "GP Discussion", "owner": user},
- pluck="reference_name",
- )
+ Comment = frappe.qb.DocType("GP Comment")
+ commented_in = (
+ frappe.qb.from_(Comment)
+ .select(Comment.reference_name)
+ .where(
+ (Comment.reference_doctype == "GP Discussion")
+ & (Comment.owner == user)
)
)
return Discussion.name.isin(commented_in)