Re: Query bug when not using ec.saveChanges

Sebastien Bigaret <[email protected]> Fri, 13 Aug 2004 00:24:31 +0200
Newsgroups gmane.comp.python.modeling
Message-ID <[email protected]>
Ernesto Revilla wrote:
> Dear all,
> 
> just a question: can't I fetch objects by attribute access, without 
> having used ec.saveChanges first? See the last 4 lines of the 
> following source code. What restrictions exist using fetch, in respect 
> with ec.saveChanges?
> 
> Thanx,
> Erny
[example snipped]

To be perfectly clear: there should not exist such a restriction.

I'm currently away from any development environment, with an access to my emails
but that's all, so I'm not able to check and diagnose this.  You have found a
bug for sure --even if, for now, I cannot be completely positive about the fact
that it can be easily solved.

  Anyhow, thanks for reporting! may I ask you to fill a bug report? I'll get
back to you next week (I can't say exactly when, I'll be extremely busy for the
10 coming days).

  In case you're in a hurry, you may want to check this by yourself by checking
EditingContext.fetch(): at the end of it, it applies the qualifier (here,
'reservations.startDay like "2004-08-09*"') to its inserted objects of the
correct type/entity.  I suspect that you get no objects because the 'like'
operator tries to compare a string to a Date object, which obviously never
selects any object.

  If this is the case, then the solution is probably to check the type of the
destination attribute (startDay), and, if it is a date, then adjust the
qualifier's value accordingly (may be changing the operator from 'like' to
'between'); or an other (more efficient?) solution could be to compare the
string with the string representation of the attribute's value... but this
would add the constraint that such a string representation should be the same
than the database's representation for dates...

Oh well, anyhow, you get the idea, don't you?-)  I'm pretty confident that the
bug is only triggered with attributes whose type is Date.

-- Sébastien.




-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285