Esempio n. 1
0
def _extend_url_parameters(url, connection_parameters):
    for key, value in parse.parse_qs(connection_parameters).items():
        if key in url.query:
            existing = url.query[key]
            if not isinstance(existing, list):
                url.query[key] = existing = utils.to_list(existing)
            existing.extend(value)
            value = existing
        else:
            url.query[key] = value
        if len(value) == 1:
            url.query[key] = value[0]
Esempio n. 2
0
def _extend_url_parameters(url, connection_parameters):
    for key, value in six.moves.urllib.parse.parse_qs(
            connection_parameters).items():
        if key in url.query:
            existing = url.query[key]
            if not isinstance(existing, list):
                url.query[key] = existing = utils.to_list(existing)
            existing.extend(value)
            value = existing
        else:
            url.query[key] = value
        if len(value) == 1:
            url.query[key] = value[0]
Esempio n. 3
0
def _sql_crit(expression, value):
    """Produce an equality expression against the given value.

    This takes into account a value that is actually a collection
    of values, as well as a value of None or collection that contains
    None.

    """

    values = utils.to_list(value, default=(None, ))
    if len(values) == 1:
        if values[0] is None:
            return expression == sql.null()
        else:
            return expression == values[0]
    elif _none_set.intersection(values):
        return sql.or_(
            expression == sql.null(),
            _sql_crit(expression,
                      set(values).difference(_none_set)))
    else:
        return expression.in_(values)
Esempio n. 4
0
def _sql_crit(expression, value):
    """Produce an equality expression against the given value.

    This takes into account a value that is actually a collection
    of values, as well as a value of None or collection that contains
    None.

    """

    values = utils.to_list(value, default=(None, ))
    if len(values) == 1:
        if values[0] is None:
            return expression == sql.null()
        else:
            return expression == values[0]
    elif _none_set.intersection(values):
        return sql.or_(
            expression == sql.null(),
            _sql_crit(expression, set(values).difference(_none_set))
        )
    else:
        return expression.in_(values)
Esempio n. 5
0
def _extend_url_parameters(url, connection_parameters):
    # TODO(zzzeek): remove hasattr() conditional when SQLAlchemy 1.4 is the
    # minimum version in requirements; call update_query_string()
    # unconditionally
    if hasattr(url, "update_query_string"):
        return url.update_query_string(connection_parameters, append=True)

    # TODO(zzzeek): remove the remainder of this method when SQLAlchemy 1.4
    # is the minimum version in requirements
    for key, value in parse.parse_qs(
            connection_parameters).items():
        if key in url.query:
            existing = url.query[key]
            if not isinstance(existing, list):
                url.query[key] = existing = utils.to_list(existing)
            existing.extend(value)
            value = existing
        else:
            url.query[key] = value
        if len(value) == 1:
            url.query[key] = value[0]

    return url
Esempio n. 6
0
    def _instantiate_fixtures(self):
        if self._instantiated_fixtures:
            return self._instantiated_fixtures

        self._instantiated_fixtures = utils.to_list(self.generate_fixtures())
        return self._instantiated_fixtures
Esempio n. 7
0
    def _instantiate_fixtures(self):
        if self._instantiated_fixtures:
            return self._instantiated_fixtures

        self._instantiated_fixtures = utils.to_list(self.generate_fixtures())
        return self._instantiated_fixtures