An opera involving primary school pupils has been cancelled after the writer refused to remove references to a gay character's sexuality.