select_for_update bug

20 views
Skip to first unread message

John

unread,
Sep 16, 2010, 6:51:14 AM9/16/10
to buzhug
There seems to be a bug, in select_for_update, namely if you only
retrieve fields of interest and set them, then later using select to
search for other fields, gives no results, even if the database tells
you that the other fields are defined.

x=db.select_for_update(['fieldA'], __id__= 5 )
x[0].update(fieldA = 'reset')
db.select(None,fieldB=db[5].fieldB)

will return the empty list, even if db[5].fieldB is defined

basically i suspect the internal representation gets broken.

normally db.cleanup() will update the internal files with the field
files so to speak, but not in this case. It may or may not be useful
to have the functionality to sync the internal files with the field
files, not sure.

this is in buzhug version 1.6 with ipython2.6

Pierre Quentel

unread,
Sep 18, 2010, 3:13:09 AM9/18/10
to buzhug
Hi,

Thanks a lot for the report ! There was a bug in the update()
function. Can you test the current version on SVN ?

Best regards,
Pierre

Arthur

unread,
Sep 20, 2010, 3:33:30 AM9/20/10
to buz...@googlegroups.com
Pierre

    I just looked at the svn version with ipython 2.6.5, and now, when one does
x=db.select_for_update(...
x[0].field = 'new value'
the new value is only set in x[0], and *not* in the database, i.e. if x[0] corresponds to db[5]
then db[5].field will remain unchanged.

also  what i meant when i said "will return the empty list" previously was that the entry with __id__ = 5 will not show up in the search results.

the quick fix to to the "select_for_update, "bug" is to just use None in the fields you are requesting to retrieve.

side note:
the __init__.py is broken as the line
from buzhug_client import ProxyBase, shouldn't be there, as there is no file ProxyBase.py

also setup.py has the wrong version listed

thanks
John
 

--
Vous recevez ce message, car vous êtes abonné au groupe Google Groupes buzhug.
Pour envoyer un message à ce groupe, adressez un e-mail à buz...@googlegroups.com.
Pour vous désabonner de ce groupe, envoyez un e-mail à l'adresse buzhug+un...@googlegroups.com.
Pour plus d'options, consultez la page de ce groupe : http://groups.google.com/group/buzhug?hl=fr


Pierre Quentel

unread,
Sep 21, 2010, 3:19:51 AM9/21/10
to buzhug


On 20 sep, 09:33, Arthur <subtlel...@gmail.com> wrote:
> Pierre
Hi,
>
>     I just looked at the svn version with ipython 2.6.5, and now, when one
> does
> x=db.select_for_update(...
> x[0].field = 'new value'
> the new value is only set in x[0], and *not* in the database, i.e. if x[0]
> corresponds to db[5]
> then db[5].field will remain unchanged.
It was the same in the previous versions : the syntax to update a
record in the database is

x[0].update(field='new value')

>
> also  what i meant when i said "will return the empty list" previously was
> that the entry with __id__ = 5 will not show up in the search results.

This is what I had with the previous version, but now this code works
as expected :

============
import buzhug

db = buzhug.Base('test.bzg')
db.create(('field1',str),('field2',int),mode="override")

for i in range(10):
db.insert('x%s' %i,2*i)

res = db.select_for_update(['field1'],field2=10)
print res[0].field1
res[0].update(field1="new value")
res = db.select_for_update(['field1'],field2=10)
print res[0].field1
============

>
> the quick fix to to the "select_for_update, "bug" is to just use None in the
> fields you are requesting to retrieve.
>
> side note:
> the __init__.py is broken as the line
> from buzhug_client import ProxyBase, shouldn't be there, as there is no file
> ProxyBase.py

Shame on me...

>
> also setup.py has the wrong version listed

Shame on me again...

>
> thanks
> John

Thank you
Pierre
> > buzhug+un...@googlegroups.com<buzhug%2Bunsu...@googlegroups.com>
> > .
> > Pour plus d'options, consultez la page de ce groupe :
> >http://groups.google.com/group/buzhug?hl=fr- Masquer le texte des messages précédents -
>
> - Afficher le texte des messages précédents -

Arthur

unread,
Sep 21, 2010, 3:49:05 AM9/21/10
to buz...@googlegroups.com
Pierre

Hi

     My mistake on testing the svn verstion, of course it's always been x[0].update to update the db.
I tested it again, and it works great!!
(as your test code also demonstrates)

thank you for fixing the bug!



Pour vous désabonner de ce groupe, envoyez un e-mail à l'adresse buzhug+un...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages