Switched to using a isinstance check on the string. Added an order by clause to dao_get_template_usage_stats_by_service, it was causing an itermitten failure in the tests.