def check_comparison(function, within_column_clause, returns_boolean,
    compare_value):
    """Because Oracle and MS SQL do not want to know Boolean and functions return 0/1 or the string 'TRUE',
    we manually have to add a comparison, but only if the function is called inside the where-clause, 
    not in the select clause.
    
    For example:
    select .. from .. where SDO_EQUAL(.., ..) = 'TRUE'
    select SDO_EQUAL(.., ..) from ..
    
    """
    if returns_boolean and not within_column_clause:
        return function == compare_value
    else:
        return function
