def _safe_match_argument(expected_type, argument_value):
    """Return a MATCH (SQL) string representing the given argument value."""
    if GraphQLString.is_same_type(expected_type):
        return _safe_match_string(argument_value)
    elif GraphQLID.is_same_type(expected_type):
        # IDs can be strings or numbers, but the GraphQL library coerces them to strings.
        # We will follow suit and treat them as strings.
        if not isinstance(argument_value, six.string_types):
            if isinstance(argument_value, bytes):  # should only happen in py3
                argument_value = argument_value.decode('utf-8')
            else:
                argument_value = six.text_type(argument_value)
        return _safe_match_string(argument_value)
    elif GraphQLFloat.is_same_type(expected_type):
        return represent_float_as_str(argument_value)
    elif GraphQLInt.is_same_type(expected_type):
        # Special case: in Python, isinstance(True, int) returns True.
        # Safeguard against this with an explicit check against bool type.
        if isinstance(argument_value, bool):
            raise GraphQLInvalidArgumentError(u'Attempting to represent a non-int as an int: '
                                              u'{}'.format(argument_value))
        return type_check_and_str(int, argument_value)
    elif GraphQLBoolean.is_same_type(expected_type):
        return type_check_and_str(bool, argument_value)
    elif GraphQLDecimal.is_same_type(expected_type):
        return _safe_match_decimal(argument_value)
    elif GraphQLDate.is_same_type(expected_type):
        return _safe_match_date_and_datetime(expected_type, (datetime.date,), argument_value)
    elif GraphQLDateTime.is_same_type(expected_type):
        return _safe_match_date_and_datetime(expected_type,
                                             (datetime.datetime, arrow.Arrow), argument_value)
    elif isinstance(expected_type, GraphQLList):
        return _safe_match_list(expected_type.of_type, argument_value)
    else:
        raise AssertionError(u'Could not safely represent the requested GraphQL type: '
                             u'{} {}'.format(expected_type, argument_value))
def _safe_match_argument ( expected_type , argument_value ) : if GraphQLString . is_same_type ( expected_type ) : return _safe_match_string ( argument_value ) elif GraphQLID . is_same_type ( expected_type ) : if not isinstance ( argument_value , six . string_types ) : if isinstance ( argument_value , bytes ) : argument_value = argument_value . decode ( 'utf-8' ) else : argument_value = six . text_type ( argument_value ) return _safe_match_string ( argument_value ) elif GraphQLFloat . is_same_type ( expected_type ) : return represent_float_as_str ( argument_value ) elif GraphQLInt . is_same_type ( expected_type ) : if isinstance ( argument_value , bool ) : raise GraphQLInvalidArgumentError ( u'Attempting to represent a non-int as an int: ' u'{}' . format ( argument_value ) ) return type_check_and_str ( int , argument_value ) elif GraphQLBoolean . is_same_type ( expected_type ) : return type_check_and_str ( bool , argument_value ) elif GraphQLDecimal . is_same_type ( expected_type ) : return _safe_match_decimal ( argument_value ) elif GraphQLDate . is_same_type ( expected_type ) : return _safe_match_date_and_datetime ( expected_type , ( datetime . date , ) , argument_value ) elif GraphQLDateTime . is_same_type ( expected_type ) : return _safe_match_date_and_datetime ( expected_type , ( datetime . datetime , arrow . Arrow ) , argument_value ) elif isinstance ( expected_type , GraphQLList ) : return _safe_match_list ( expected_type . of_type , argument_value ) else : raise AssertionError ( u'Could not safely represent the requested GraphQL type: ' u'{} {}' . format ( expected_type , argument_value ) )
Return a MATCH (SQL) string representing the given argument value.