CAST to TEXT required to avoid sql errors