marten
marten copied to clipboard
Missing temp CTE table on Patch call
I am in the process of migrating from v3 to v5 and come across a change to the Patch support. I'm trying to narrow it down some more now, but the issue appears to be if the Patch filter is a little complex:
this._db.Patch<User>(u => u.ExternalReferences.References.Any(r => r.Reference ==externalReference))
.Set(u => u.PhotoUrl, photoUrl);
The above fails with:
````42P01: relation "mt_temp_id_list2cte" does not exist```
The generated SQL look like (as 2x:
update public.mt_doc_user as d
set data = public.mt_transform_patch_doc(data, :p1), mt_last_modified = (now() at time zone 'utc'), mt_version = :p2
where ctid in (select ctid from mt_temp_id_list2CTE);
update public.mt_doc_user as d set primary_email = data ->> 'PrimaryEmail', member_of = CAST(ARRAY(SELECT jsonb_array_elements_text(CAST(data ->> 'MemberOf' as jsonb))) as varchar[]), secondary_emails = CAST(ARRAY(SELECT jsonb_array_elements_text(CAST(data ->> 'SecondaryEmails' as jsonb))) as varchar[])
where ctid in (select ctid from mt_temp_id_list2CTE);
That is the entire statement, where you can see no mt_temp_id_list2CTE is generated
Very, very nasty SQL, but actually not that rough to fix most likely. I'll try to take a look at this today
@jeremydmiller Many thanks. It's not ideal what I'm doing here, granted (I will look at improving :)), but this did indeed use to work in v3.
This one's a little bigger than I feared. And it impacts several other cases like DeleteWhere()
. Sorry to do this, but this might get kicked back yet again.
FINALLY.