def update(self, **values):
    from olo import PostgreSQLDataBase
    expression = self._get_expression()
    if (not expression):
        raise ExpressionError('Cannot execute update because of without expression')
    (assignments, _, _) = self._model_class._split_attrs(values)
    update_sql_ast = ['UPDATE', ['TABLE', self.table_name], ['SET', (['SERIES'] + [asg.get_sql_ast() for asg in assignments])]]
    db = self._model_class._get_db()
    if isinstance(db, PostgreSQLDataBase):
        pk = self._model_class.get_singleness_pk_field()
        if self._order_by:
            base_sql_ast = self.map(pk).for_update()._get_base_sql_ast()
            sql_ast = self.get_sql_ast(base_sql_ast=base_sql_ast)
            update_sql_ast.append(['WHERE', ['BINARY_OPERATE', 'IN', ['QUOTE', pk.name], ['BRACKET', sql_ast]]])
            with self.db.transaction():
                rows = self._get_rv_by_sql_ast(sql_ast=update_sql_ast)
        else:
            with self.db.transaction():
                rows = self._get_rv(base_sql_ast=update_sql_ast)
    else:
        with self.db.transaction():
            rows = self._get_rv(base_sql_ast=update_sql_ast)
    return rows
def update(self, **values):
    from olo import PostgreSQLDataBase
    expression = self._get_expression()
    if (not expression):
        raise ExpressionError('Cannot execute update because of without expression')
    (assignments, _, _) = self._model_class._split_attrs(values)
    update_sql_ast = ['UPDATE', ['TABLE', self.table_name], ['SET', (['SERIES'] + [asg.get_sql_ast() for asg in assignments])]]
    db = self._model_class._get_db()
    if isinstance(db, PostgreSQLDataBase):
        pk = self._model_class.get_singleness_pk_field()
        if self._order_by:
            base_sql_ast = self.map(pk).for_update()._get_base_sql_ast()
            sql_ast = self.get_sql_ast(base_sql_ast=base_sql_ast)
            update_sql_ast.append(['WHERE', ['BINARY_OPERATE', 'IN', ['QUOTE', pk.name], ['BRACKET', sql_ast]]])
            with self.db.transaction():
                rows = self._get_rv_by_sql_ast(sql_ast=update_sql_ast)
        else:
            with self.db.transaction():
                rows = self._get_rv(base_sql_ast=update_sql_ast)
    else:
        with self.db.transaction():
            rows = self._get_rv(base_sql_ast=update_sql_ast)
    return rows