Fix Thorim apply sql.