Correct type comparison when switching database
Add refresh on switching database to avoid manual refresh