Fix wrong management of capabilities in queries

Change-Id: I7dc0753c65be2b3b6356af3b3dccc5cbdd9954bd