fix sql output when using database routers