Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion pymongo find_and_modify not honoring sort?
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Walter Woods  
View profile  
 More options Sep 25 2012, 10:18 pm
From: Walter Woods <woodswal...@gmail.com>
Date: Tue, 25 Sep 2012 19:18:08 -0700 (PDT)
Local: Tues, Sep 25 2012 10:18 pm
Subject: Re: pymongo find_and_modify not honoring sort?

Just want to vote in support that this should be fixed to take
key_or_list... after all, a dict in python can change sort after the
definition, so something like { 'b': 1, 'a': -1 } would end up sorting on
'a' descending BEFORE 'b' ascending, which isn't what would be intended.

On Wednesday, December 14, 2011 4:21:44 PM UTC-8, Zac Witte wrote:

> I'm I missing something here?

> ubuntu@mongo1:~/pubnub-analytics$ python
> Python 2.7.1+ (r271:86832, Apr 11 2011, 18:13:53)
> [GCC 4.5.2] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> from pymongo import Connection
> >>> from pymongo import ASCENDING, DESCENDING
> >>> conn = Connection()
> >>> db = conn.pb2
> >>> db.log_files.find_and_modify(
> ...     query={'status':'unprocessed'},
> ...     update={'$set':{}},
> ...     sort=[('file_name',ASCENDING)],
> ...     new=True)
> {u'status': u'unprocessed', u'file_name':
> u'2011-12-03_23:04:34.288091_50.18.36.76.log.bz2', u'_id':
> ObjectId('4ee805931d011c644f003260')}
> >>> db.log_files.find_one({'status':'unprocessed'})
> {u'status': u'unprocessed', u'file_name':
> u'2011-12-03_23:04:34.288091_50.18.36.76.log.bz2', u'_id':
> ObjectId('4ee805931d011c644f003260')}
> >>> db.log_files.find_one({'status':'unprocessed'},
> sort=[('file_name',ASCENDING)])
> {u'status': u'unprocessed', u'file_name':
> u'2011-09-30_10:48:23.843037_46.137.255.217.log', u'_id':
> ObjectId('4ee805981d011c644f00916c'), u'end_time':
> datetime.datetime(2011, 12, 14, 2, 35, 52, 160000)}


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.