graphql-engine icon indicating copy to clipboard operation
graphql-engine copied to clipboard

server/refactor: use `Set`/`HashSet` to deduplicate function names in `runTxWithMetadataCheck`

Open plcplc opened this issue 2 years ago • 4 comments

The root cause of graphql-engine#8643: Migrations fail if duplicate functions exist is that the list of functions to consider for metadata diff checks ends up with duplicates when a function is tracked both as root field and as computed field:

https://github.com/hasura/graphql-engine/blob/f80ec1d543e0e3e4711fe72bb8f19c097e6897c1/server/src-lib/Hasura/Backends/Postgres/DDL/RunSQL.hs#L303

The proper fix is to ensure that we use sets/hashsets in all the functions involved instead of lists in order to statically ensure no duplicates appear by accident.

plcplc avatar Aug 30 '22 11:08 plcplc

Hi, can I have a go at this issue? Thank you

Declan-Y avatar Oct 02 '22 09:10 Declan-Y

Hey, @Declan-Y thank you for your interest! Feel free to work on this and open a PR.

Stefmore02 avatar Oct 03 '22 20:10 Stefmore02

Doesn't the nub function remove duplicates?

daniel-shuy avatar Oct 12 '22 07:10 daniel-shuy

Sorry never mind, I just noticed that in b0d2262, nub was added as a quick workaround, but is an inefficient way to remove duplicates

daniel-shuy avatar Oct 12 '22 07:10 daniel-shuy