First thing to check would be if this is even possible. I am assuming you use PostgreSQL since you linked to CloudSQL for postgres, and Ecto uses “binary” protocol to talk to it:
And this differs from other clients in several ways, for example in the way that timestamps are returned (always UTC). Being a binary protocol, it may not support comments at all. You should probably check if you can add a comment to MyApp.Repo.query!(...) and see if it even gets passed to PostgreSQL before you move any further.
For PostgreSQL proper at least, Repo.query (and friends) should work fine.
I pass in some fairly gigantic DO blocks which include PostgreSQL single line comments, multi-line comments, “dollar-sign quoting”, nested dollar-sign quoting, etc. into individual Repo.query calls and I’ve had no issues.
I would expect that anything “within reason” in this regard shouldn’t cause problems.