Re: INSERT and .refresh() problems

Faber <[email protected]> Mon, 27 Jun 2005 04:18:04 +0200
Newsgroups gmane.comp.web.skunkweb
Organization FaberBox
Message-ID <[email protected]>
On Monday 27 June 2005 04:03, Jacob Smullyan wrote:

> >   File "pydo/base.py", line 626, in refresh
> >     raise ValueError, "current object doesn't exist in database!"
> > ValueError: current object doesn't exist in database!

[cut on the test case]

> The foreign key relationship is actually irrelevant, since presumably
> you are getting the failure at the refresh itself.

Yes

[cut]

> One other thing, btw -- you do not need to refresh to get an
> autoincrement or sequence value.  With sequences, PyDO fetches the
> sequence first and explicitly inserts it; with autoincrement, the
> autoincrement value is found during the new operation.  If this were
> not the case, refresh would be impossible when the unique constraint
> is a sequence/autoincrement field.

Maybe it's a MY fault, because I declared the ID field as Unique('id') and 
not Sequence('id'); anyway, with the .refresh() call it worked in the 
previous beta, not in the latest.

Now I've changed it in Sequence('id') and I can use it without 
the .refresh() call, so for me it's ok. It's up to you to decide if 
the .refresh() call in my previous situation is a bug or not.

class Test(PyDO):
	connectionAlias = 'main_db'
	fields = (Unique('id'), Unique('description'))

I've the reported error on following code:

a = Test.new(description = "This is a test")
a.refresh()

Using Sequence('id') the .refresh() call works, even if I don't need it 
anymore  ;)

Regards

-- 
Faber
http://www.faberbox.com/

There are not many persons who know what wonders are opened to them in the 
stories and visions of their youth; for when as children we learn and 
dream, we think but half-formed thoughts, and when as men we try to 
remember, we are dulled and prosaic with the poison of life. -- H.P. 
Lovecraft


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click