patch find_by_sql and count_by_sql