Postgres Query Syntax Error

so I am using erpnext and frappe version 14 with postgres version 14

I installed the healthcare app on the site (all this locally with mac using docker images/containers)

While creating a patient - I was able to do that successfully, but while trying to view that particular patient I get this -

### Route

Form/Patient/Yo

### Traceback

Syntax error in query:
select “company”, sum(grand_total) as grand_total, sum(base_grand_total) as base_grand_total, MAX(docstatus, tabSales Invoice) as “tabSales Invoice.docstatus, tabSales Invoice.modified”
from “tabSales Invoice”
where “tabSales Invoice”.“docstatus” = ‘1’ and “tabSales Invoice”.“customer” = ‘Yo’ and coalesce(“tabSales Invoice”.“posting_date”, ‘0001-01-01 00:00:00.000000’) between ‘2023-04-01’ AND ‘2024-03-31’
group by company
order by “tabSales Invoice”.docstatus asc, “tabSales Invoice”.“modified” DESC
Traceback (most recent call last):
File “apps/frappe/frappe/app.py”, line 83, in application

return super().sql(modify_query(query), modify_values(values), *args, **kwargs)
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File “apps/frappe/frappe/database/database.py”, line 229, in sql
self._cursor.execute(query, values)
psycopg2.errors.SyntaxError: syntax error at or near “Invoice”
LINE 1: …tal) as base_grand_total, MAX(docstatus, tabSales Invoice) a…
^

### Request Data

{
“type”: “GET”,
“args”: {
“doctype”: “Patient”,
“name”: “Yo”
},
“headers”: {},
“error_handlers”: {},
“url”: “/api/method/frappe.desk.form.load.getdoc”
}

### Response Data

{
“exception”: “”
}

Shouldn’t this be impossible to come ? Is this some version mismatch issue - anybody else faced this ?