Fix permissions check for query creation.