Open sblackstone opened 8 months ago
I took a look at fixing this issue - it seems a bit thorny due to the requirement that we also support "Soft Delete" and "AllowGlobalUpdate"
Soft delete generates the same kind of broken SQL at the moment......
The query will need to end up looking like this...
DELETE FROM multi_tables
WHERE EXISTS (
SELECT 1
FROM (VALUES ('val1', 'val2', 'val3')) AS Subquery(field1, field2, field3)
WHERE multi_tables.field1 = Subquery.field1
AND multi_tables.field2 = Subquery.field2
AND multi_tables.field3 = Subquery.field3
);
GORM Playground Link
https://github.com/go-gorm/playground/pull/679
Description
When using "delete" on a model that has a composite primary key, GORM generates invalid SQL for sqlserver... The playground PR above demonstrates this...