c05de08a3b
I *think* this works; in my test instance (with no federated notes…) the generated query looks correct, and PostgreSQL doesn't complain.