fix to_sql output on eager loaded relations