def _parse_comparison(sql, example, anonymize_values):
Parse the part relative to a comparison in the SQL query.
successful_copy = True
for item in sql:
if item.ttype == sqlparse.tokens.Text.Whitespace:
continue
if _is_identifier(item):
successful_copy = _parse_identifier(item, example,
anonymize_values) and successful_copy
continue
if _is_comparison_operator(item):
_add_simple_step(item, example)
continue
if _is_literal(item):
prev_len = len(example.gold_sql_query.actions)
successful_copy = _add_simple_value(item, example,
anonymize_values) and successful_copy
if len(example.gold_sql_query.actions) == prev_len:
raise ValueError(
"Gold query did not change length when adding simple value!")
continue
if _is_parenthesis(item):
successful_copy = populate_sql(item, example,
anonymize_values) and successful_copy
continue
if _is_function(item):
successful_copy = _parse_function(item, example,
anonymize_values) and successful_copy
continue
if _is_operation(item):
successful_copy = _parse_operation(item, example,
anonymize_values) and successful_copy
continue
_debug_state(item, example)
raise ParseError("Incomplete _parse_comparison")
return successful_copy
def _parse_where(sql, example, anonymize_values):
Parse the part relative to the WHERE clause of the SQL query.