Tuesday, July 31, 2012

Re: Problem with order_by on one record only

Just to update this in case anyone else has a similar problem...
I used a DecimalField where the database had a Float value, so I switched it to a FloatField in my models and it fixed the problem.  Of course, some precision may be lost in doing this, but considering the values I'm reading are actually fixed point to begin with, I don't really mind as the precision was set to a certain amount before it ever hit my database.

Hope this helps someone else down the line.

On Friday, June 15, 2012 5:42:28 PM UTC-4, Alex Umrysh wrote:
I'm having a strange error on an object query when I try to do negative order_by. This is on an Oracle 11 database with Django 1.4
it looks something like:

MyModel.objects.filter(pk=N).order_by('-datetime')[:5]

This gives me valid data for all values of N in the database except for one specific record.
This one record works fine when the order_by is on 'datetime', but '-datetime' doesn't work.  using .latest('datetime') appears to do the same thing (under the hood), so there's no difference in the behavior there.

I'm not sure what the issue is with this specific object, but it does use more columns than the rest of the objects in the database.

I have looked at the datetime objects, and they all appear to be good.
I added some additional model fields based on the changes my DBA made to this table, but I'm not certain why this would cause this one specific object to return nothing where others do, as the data appears good.
any ideas where to look?
I would provide more code but it's of a confidential nature so I'll have to scrub any names before I post the models, so I'm hoping someone has an idea or hunch before I have to do that.

Thanks, and sorry for not posting much code.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/24rdpeCNuNIJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment