summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorBoris Pavlovic <boris@pavlovic.me>2012-12-24 15:19:28 +0400
committerBoris Pavlovic <boris@pavlovic.me>2013-01-23 17:18:10 +0400
commit28191baa2b1a65fb86bbbbfc0974495059db6d42 (patch)
treed1d023297660920e693fe99d39f8499cab1c85cd /nova/api
parentbb108c6bd359e788e0f4cfc53f5933d134fc7cc4 (diff)
downloadnova-28191baa2b1a65fb86bbbbfc0974495059db6d42.tar.gz
nova-28191baa2b1a65fb86bbbbfc0974495059db6d42.tar.xz
nova-28191baa2b1a65fb86bbbbfc0974495059db6d42.zip
Provide creating real unique constraints for columns
Main issue is that we can't create unique constraint for columns, because we are using soft deletion of entries (set `deleted` column to True). The main idea is to use `deleted` columns to create unique constraint for columns. For example (`col1`, `deleted`). To make (`col1`, `deleted`) unique after entry deletion, we should assign the value of `id` to `deleted` column. Change type of `deleted` column from Boolean to table.id.type for all tables. Change models.soft_delete() method to assign table.id instead of True to `deleted` column. Change query.soft_delete() method to assign literal_column("id") instead of True Change in db.models all occurrences of Table.deleted == False => Table.deleted == correct_type (0 or "") Value of `deleted` property of entries is used in public nova api. To keep API as is, we should change XMLDictSerializer by converting the type of `deleted` property to string representation of boolean. Change db.api.model_query() method to make it work with different types of `deleted` column. If we are using as model that is not subclass of NovaBase we should set parameter base_model as subclass of NovaBase that corresponds to model. Change in db.api all occurrences of using model_query with model that is not subclass of NovaBase. blueprint db-unique-keys Change-Id: Ie1f67f49a5d085e6371efb63fc23a1c8b25d9464
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/wsgi.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/nova/api/openstack/wsgi.py b/nova/api/openstack/wsgi.py
index 733685b14..8b593d742 100644
--- a/nova/api/openstack/wsgi.py
+++ b/nova/api/openstack/wsgi.py
@@ -406,6 +406,8 @@ class XMLDictSerializer(DictSerializer):
if k in attrs:
result.setAttribute(k, str(v))
else:
+ if k == "deleted":
+ v = str(bool(v))
node = self._to_xml_node(doc, metadata, k, v)
result.appendChild(node)
else: