Fix EZP-22333: SQL error in tagcloud with object state policies

Backport of the same fix from ezdemo
(cherry picked from commit 5fde79c476dfd7d27814c218ee52905f2c183db0)