def apply_limit_to_sql(cls, sql, limit, database):
        """Alters the SQL statement to apply a LIMIT clause"""
        if cls.limit_method == LimitMethod.WRAP_SQL:
            sql = sql.strip('\t\n ;')
            qry = (
                select('*')
                .select_from(
                    TextAsFrom(text(sql), ['*']).alias('inner_qry'),
                )
                .limit(limit)
            )
            return database.compile_sqla_query(qry)
        elif LimitMethod.FORCE_LIMIT:
            parsed_query = sql_parse.ParsedQuery(sql)
            sql = parsed_query.get_query_with_new_limit(limit)
        return sql
def apply_limit_to_sql ( cls , sql , limit , database ) : if cls . limit_method == LimitMethod . WRAP_SQL : sql = sql . strip ( '\t\n ;' ) qry = ( select ( '*' ) . select_from ( TextAsFrom ( text ( sql ) , [ '*' ] ) . alias ( 'inner_qry' ) , ) . limit ( limit ) ) return database . compile_sqla_query ( qry ) elif LimitMethod . FORCE_LIMIT : parsed_query = sql_parse . ParsedQuery ( sql ) sql = parsed_query . get_query_with_new_limit ( limit ) return sql
Alters the SQL statement to apply a LIMIT clause