Bugfix - type casting in query