# Path: oslo_db/sqlalchemy/update_match.py
# def update_on_match(
#     query,
#     specimen,
#     surrogate_key,
#     values=None,
#     attempts=3,
#     include_only=None,
#     process_query=None,
#     handle_failure=None
# ):
# def manufacture_persistent_object(
#         session, specimen, values=None, primary_key=None):
# def manufacture_entity_criteria(entity, include_only=None, exclude=None):
# def manufacture_criteria(mapped, values):
# def _sql_crit(expression, value):
# def update_returning_pk(query, values, surrogate_key):
# def _assert_single_row(rows_updated):
# def _pk_strategy_refetch(query, mapper, values, surrogate_key):
# def _pk_strategy_returning(query, mapper, values, surrogate_key):
# def _pk_strategy_mysql_last_insert_id(query, mapper, values, surrogate_key):
# def _update_stmt_from_query(mapper, query, values):
# class CantUpdateException(Exception):
# class NoRowsMatched(CantUpdateException):
# class MultiRowsMatched(CantUpdateException):


from oslo_utils import timeutils
from oslo_db.sqlalchemy import update_match
import sqlalchemy.orm



class Query(sqlalchemy.orm.query.Query):
    """Subclass of sqlalchemy.query with soft_delete() method."""
    def soft_delete(self, synchronize_session='evaluate'):
        entity = self.column_descriptions[0]['entity']
        return self.update({'deleted': entity.id,
                            'updated_at': entity.updated_at,
                            'deleted_at': timeutils.utcnow()},
                           synchronize_session=synchronize_session)

    def update_returning_pk(self, values, surrogate_key):
        """Perform an UPDATE, returning the primary key of the matched row.

        This is a method-version of
        oslo_db.sqlalchemy.update_match.update_returning_pk(); see that
        function for usage details.

        """
        return update_match.update_returning_pk(self, values, surrogate_key)

    def update_on_match(self, specimen, surrogate_key, values, **kw):
        """Emit an UPDATE statement matching the given specimen.

        This is a method-version of
        oslo_db.sqlalchemy.update_match.update_on_match(); see that function
        for usage details.

        """

# Path: oslo_db/sqlalchemy/update_match.py
# def update_on_match(
#     query,
#     specimen,
#     surrogate_key,
#     values=None,
#     attempts=3,
#     include_only=None,
#     process_query=None,
#     handle_failure=None
# ):
# def manufacture_persistent_object(
#         session, specimen, values=None, primary_key=None):
# def manufacture_entity_criteria(entity, include_only=None, exclude=None):
# def manufacture_criteria(mapped, values):
# def _sql_crit(expression, value):
# def update_returning_pk(query, values, surrogate_key):
# def _assert_single_row(rows_updated):
# def _pk_strategy_refetch(query, mapper, values, surrogate_key):
# def _pk_strategy_returning(query, mapper, values, surrogate_key):
# def _pk_strategy_mysql_last_insert_id(query, mapper, values, surrogate_key):
# def _update_stmt_from_query(mapper, query, values):
# class CantUpdateException(Exception):
# class NoRowsMatched(CantUpdateException):
# class MultiRowsMatched(CantUpdateException):


# Path: oslo_db/sqlalchemy/orm.py
from oslo_utils import timeutils
from oslo_db.sqlalchemy import update_match
import sqlalchemy.orm




class Query(sqlalchemy.orm.query.Query):
    """Subclass of sqlalchemy.query with soft_delete() method."""
    def soft_delete(self, synchronize_session='evaluate'):
        entity = self.column_descriptions[0]['entity']
        return self.update({'deleted': entity.id,
                            'updated_at': entity.updated_at,
                            'deleted_at': timeutils.utcnow()},
                           synchronize_session=synchronize_session)

    def update_returning_pk(self, values, surrogate_key):
        """Perform an UPDATE, returning the primary key of the matched row.

        This is a method-version of
        oslo_db.sqlalchemy.update_match.update_returning_pk(); see that
        function for usage details.

        """
        return update_match.update_returning_pk(self, values, surrogate_key)

    def update_on_match(self, specimen, surrogate_key, values, **kw):
        """Emit an UPDATE statement matching the given specimen.

        This is a method-version of
        oslo_db.sqlalchemy.update_match.update_on_match(); see that function
        for usage details.

        """

        return update_match.update_on_match(