Type coercion for queries