Fixed queries during managed meta-data creation. Part of #2327.