order traits returned within events

- we order the traits by key in all the backends except sql. this
keeps sql inline.
- this reverts a patch to sort traits post query in test.

Change-Id: I17009bdb01106dc07659a9198da2090ec63bcf51
Closes-Bug: #1423714
This commit is contained in:
gordon chung 2015-02-19 19:21:32 -05:00
parent 534048d96c
commit 4c4734c448
2 changed files with 3 additions and 3 deletions

View File

@ -313,7 +313,8 @@ class Connection(base.Connection):
.add_columns(models.TraitText.key, sa.null(), .add_columns(models.TraitText.key, sa.null(),
sa.null(), sa.null(), models.TraitText.value)) sa.null(), sa.null(), models.TraitText.value))
for id_, key, t_date, t_int, t_float, t_text in trait_q.all(): for id_, key, t_date, t_int, t_float, t_text in (
trait_q.order_by('2')).all():
if t_int: if t_int:
dtype = api_models.Trait.INT_TYPE dtype = api_models.Trait.INT_TYPE
val = t_int val = t_int

View File

@ -3229,8 +3229,7 @@ class GetEventTest(EventTestBase):
self.assertEqual(event.generated, self.assertEqual(event.generated,
self.event_models[i].generated) self.event_models[i].generated)
model_traits = self.event_models[i].traits model_traits = self.event_models[i].traits
for j, trait in enumerate(sorted(event.traits, for j, trait in enumerate(event.traits):
key=operator.attrgetter("name"))):
if trait.dtype == event_models.Trait.DATETIME_TYPE: if trait.dtype == event_models.Trait.DATETIME_TYPE:
self.assertIsInstance(trait.value, datetime.datetime) self.assertIsInstance(trait.value, datetime.datetime)
self.assertEqual(trait.value, model_traits[j].value) self.assertEqual(trait.value, model_traits[j].value)