summaryrefslogtreecommitdiff
path: root/oslo_db/sqlalchemy/session.py
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2015-03-23 15:19:22 +0000
committerGerrit Code Review <review@openstack.org>2015-03-23 15:19:22 +0000
commit3cf218d0961cf1e0dc2c6f58602c307f43ac6ad9 (patch)
tree188e99af080ba541387b20bada25917841e845ad /oslo_db/sqlalchemy/session.py
parentadfb47387655d13e1c2fb7da0b63781500c7c69c (diff)
parente0baed656edf470a22d7a5f1610b70017002b611 (diff)
downloadoslo-db-3cf218d0961cf1e0dc2c6f58602c307f43ac6ad9.tar.gz
Merge "Implement generic update-on-match feature"
Diffstat (limited to 'oslo_db/sqlalchemy/session.py')
-rw-r--r--oslo_db/sqlalchemy/session.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/oslo_db/sqlalchemy/session.py b/oslo_db/sqlalchemy/session.py
index 6a0355d..ce347ce 100644
--- a/oslo_db/sqlalchemy/session.py
+++ b/oslo_db/sqlalchemy/session.py
@@ -297,6 +297,7 @@ from oslo_db import exception
from oslo_db import options
from oslo_db.sqlalchemy import compat
from oslo_db.sqlalchemy import exc_filters
+from oslo_db.sqlalchemy import update_match
from oslo_db.sqlalchemy import utils
LOG = logging.getLogger(__name__)
@@ -599,6 +600,27 @@ class Query(sqlalchemy.orm.query.Query):
'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(
+ self, specimen, surrogate_key, values, **kw)
+
class Session(sqlalchemy.orm.session.Session):
"""Custom Session class to avoid SqlAlchemy Session monkey patching."""