Returns an instance with the new pairs appended to it.

This method MUST retain the state of the current instance, and return
an instance that contains the modified query

If the pair already exists the value will be added to it.
326081
public function append($query): self
    {
        if ($query instanceof UriComponentInterface) {
            $query = $query->getContent();
        }

        $pairs = array_merge($this->pairs, QueryString::parse($query, $this->separator, PHP_QUERY_RFC3986));
        if ($pairs === $this->pairs) {
            return $this;
        }

        $clone = clone $this;
        $clone->pairs = array_filter($pairs, [$this, 'filterEmptyValue']);

        return $clone;
    }
1191170
function newInstance (result) {
    // return raw result or new instnace
    return this.args.raw
        ? result
        : this.model.newInstance({
            allow: this.args.allow,
            model: this.model,
            plain: this.args.plain,
            raw: result,
            session: this.session,
        })
}
342716
def _add(self, obj, data, **kwargs):
        
        if isinstance(obj, sqlalchemy.orm.query.Query):
            obj = obj.one()
        obj = self.preprocessing(obj=obj or self.table)\
            .add(self.session, data, self.table)
        self.session.add(obj)
        if kwargs.get('commit', self.commit) is True:
            try:
                self.session.commit()
            except AssertionError:
                transaction.commit()
        return obj
930287
def distinct(self):
        
        new_query_set = self.clone()
        new_query_set.query.distinct = True
        return new_query_set
394771
async def add(self, *instances, using_db=None) -> None:
        
        if not instances:
            return
        if self.instance.id is None:
            raise OperationalError(
                "You should first call .save() on {model}".format(model=self.instance)
            )
        db = using_db if using_db else self.model._meta.db
        through_table = Table(self.field.through)
        select_query = (
            db.query_class.from_(through_table)
            .where(getattr(through_table, self.field.backward_key) == self.instance.id)
            .select(self.field.backward_key, self.field.forward_key)
        )
        query = db.query_class.into(through_table).columns(
            getattr(through_table, self.field.forward_key),
            getattr(through_table, self.field.backward_key),
        )

        if len(instances) == 1:
            criterion = getattr(through_table, self.field.forward_key) == instances[0].id
        else:
            criterion = getattr(through_table, self.field.forward_key).isin(
                [i.id for i in instances]
            )

        select_query = select_query.where(criterion)

        already_existing_relations_raw = await db.execute_query(str(select_query))
        already_existing_relations = {
            (r[self.field.backward_key], r[self.field.forward_key])
            for r in already_existing_relations_raw
        }

        insert_is_required = False
        for instance_to_add in instances:
            if instance_to_add.id is None:
                raise OperationalError(
                    "You should first call .save() on {model}".format(model=instance_to_add)
                )
            if (self.instance.id, instance_to_add.id) in already_existing_relations:
                continue
            query = query.insert(instance_to_add.id, self.instance.id)
            insert_is_required = True
        if insert_is_required:
            await db.execute_query(str(query))
1279421
def add(self, value, session=None, **kwargs):
        ''''''
        s, instance = self.session_instance('add', value, session, **kwargs)
        return s.add(instance)
786473
def get_nowait(self):
        
        new_get = Future()

        with self._lock:
            if not self._get.done():
                raise QueueEmpty
            get, self._get = self._get, new_get

        hole = get.result()
        if not hole.done():
            # Restore the unfinished hole.
            new_get.set_result(hole)
            raise QueueEmpty

        node = hole.result()
        value = node.value
        new_hole, node.next = node.next, None
        new_get.set_result(new_hole)
        return value
1356961
def addObject(self, pairs, name=None):
    
    if name is None:
      name = len(self.objects)

    self.objects[name] = pairs
1328094
function newRecordInstance (raw) {
    // return raw data
    if (this.query.args.raw) {
        return raw
    }
    // return new model instance
    else {
        return this.query.model.newInstance({
            model: this.query.model,
            plain: this.query.args.plain,
            raw: raw,
            session: this.query.session,
        })
    }
}
944210
def retrieve_instances(self, query=None):
        
        if query is None:
            data = javabridge.call(self.jobject, "retrieveInstances", "()Lweka/core/Instances;")
        else:
            data = javabridge.call(self.jobject, "retrieveInstances", "(Ljava/lang/String;)Lweka/core/Instances;")
        return Instances(data)
1269484
def update_or_create(self, attributes, values=None, joining=None, touch=True):
        
        if values is None:
            values = {}

        instance = self._query.where(attributes).first()

        if instance is None:
            return self.create(values, joining, touch)

        instance.fill(**values)

        instance.save({"touch": False})

        return instance
326971
def modified_created(instance):
    
    if 'modified' in instance and 'created' in instance and \
            instance['modified'] < instance['created']:
        msg = "'modified' (%s) must be later or equal to 'created' (%s)"
        return JSONError(msg % (instance['modified'], instance['created']),
                         instance['id'])
419419
def _fetch_new(&client_block)
      if (@never_block || (_total_current_size < @max_size))
        if client_block.arity == 0
          nc = yield
        else
          nc = yield @sessions_key
        end
        HotTub.logger.info "[HotTub] Adding client: #{nc.class.name} to #{@name}." if HotTub.log_trace?
        nc
      end
    end
31902
def first_or_new(self, _attributes=None, **attributes):
        
        if _attributes is not None:
            attributes.update(_attributes)

        instance = self._query.where(attributes).first()

        if instance is None:
            instance = self._related.new_instance()
            self._set_foreign_attributes_for_create(instance)

        return instance
1214826
def new_vertex(self):
    
    vertex = Vertex(len(self.vertices))
    self.vertices.append(vertex)
    return vertex
1146209
def copy(self):
    ''''''
    if self.object_getattr is Query.object_getattr:
      other = Query(self.key)
    else:
      other = Query(self.key, object_getattr=self.object_getattr)
    other.limit = self.limit
    other.offset = self.offset
    other.offset_key = self.offset_key
    other.filters = self.filters
    other.orders = self.orders
    return other
161316
def singleton(cls):
    '''
    
    '''

    cls.__new_original__ = cls.__new__

    @wraps(cls.__new__)
    def singleton_new(cls, *args, **kw):
        it = cls.__dict__.get('__it__')
        if it is not None:
            return it

        cls.__it__ = it = cls.__new_original__(cls, *args, **kw)
        it.__init_original__(*args, **kw)
        return it

    cls.__new__ = singleton_new
    cls.__init_original__ = cls.__init__
    cls.__init__ = object.__init__

    return cls