Re: INSERT and .refresh() problems

Jacob Smullyan <[email protected]> Sun, 26 Jun 2005 22:47:31 -0400
Newsgroups gmane.comp.web.skunkweb
Message-ID <[email protected]>
On Mon, Jun 27, 2005 at 04:18:04AM +0200, Faber wrote:
> On Monday 27 June 2005 04:03, Jacob Smullyan wrote:
> 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()

I don't know exactly why it worked before, but I think it shouldn't
have!  Because the object "a" should have id == None,
description=='This is a test', and refresh does a getUnique with all
the unique constraints present.  If you set verbose to true when you
initAlias, you should see that it would be querying for "id IS NULL
and description = 'This is a test'".

Perhaps new() should raise an error when not null unique constraints
that aren't Sequences aren't provided to it, before the insert is
submitted to the backend?  You'd then have bombed out a bit earlier
and the error message would have been more relevant.

js


-- 
Jacob Smullyan
signature.asc (application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFCv2jDuqamFyFXXLIRAmqeAJ9+zsveJKGitYaZAnZQ1rCuINSt4ACeMmcm
tZPMTH6NX1x2Fj78G0qUwFg=
=Y3xN
-----END PGP SIGNATURE-----