Re: [Modeling-users] Strange date conversion in fetch qualifier
Status: Abandoned
Brought to you by:
sbigaret
From: Mario R. <ma...@ru...> - 2003-12-01 17:16:32
|
Hi Lukasz, not clear to me why you are concatenating the qualifer string the way you are. Using mx.DateTime for date fields, I can then do this in my qualifier to include a condition on the date value of the table column "createdate" for the fetch: q_part_whatever =3D ' ... ' q_date =3D 'createdate<"%s"' %(customObject.getCreatedate()) qualifier =3D ' AND '.join([ q_part_whatever, q_date]) This works. Not sure if there is a nicer way to do it though. This reminds me of a problem that I meant to report though: - I create an object with a date attribute (value for attribute set with mx.DateTime.now()), but without doing ec.saveChanges() - then if I fetch the object with ec.fetch('MyClass', qualifier =3D 'createdate=3D=3D"%s"' = %(myObject.getDateattr()) ) the fetch does not return the newly created object. This may be a bug, but I can confirm after playing with it further. Cheers, mario > Hi > > I've got some problem with conditions that using dates. The following > examlple shows this. > > ERD: > MaWychowawce > Klasa|<<--------------->|Nauczyciel > -----| |------------ > |attr: DataUrodzenia > > code: > --------------------------------------------------------------------- > warunek=3D'MaWychowawce.DataUrodzenia > '+str(DateTime(1970,1,1)) > print warunek > klasy=3DEC.fetch('Klasa',qualifier=3Dwarunek) > --------------------------------------------------------------------- > > Printed qualifier look like this: MaWychowawce.DataUrodzenia > =20 > 1970-01-01 > 00:00:00.00 > I've tried with: MaWychowawce.DataUrodzenia > '1970-01-01 00:00:00.00' = =20 > but > it also didn't work > Conditions on another attributes in 'Nauczyciel' works perfectly. > > error > --------------------------------------- > Couldn't evaluate expression SELECT DISTINCT t0.KLASA_ID, t0.NAZWA, > t0.PROFIL, t0.WYCHOWAWCA_ID FROM KLASA t0 INNER JOIN NAUCZYCIEL t1 ON > t0.WYCHOWAWCA_ID=3Dt1.NAUCZYCIEL_ID WHERE t1.DATA_URODZENIA > '1970'. =20= > Reason: > libpq.OperationalError:ERROR: bad timestamp external representation =20= > '1970' > > Traceback (most recent call last): > File "<stdin>", line 1, in ? > File "Baza.py", line 45, in PobierzDane > klasy=3DEC.fetch('Klasa',qualifier=3Dwarunek) > File "C:\PROGRA~1\Zope2.6.2\bin\Modeling\EditingContext.py", line =20= > 1419, in > fetch > return self.objectsWithFetchSpecification(fs) > File "C:\PROGRA~1\Zope2.6.2\bin\Modeling\EditingContext.py", line =20= > 1302, in > objectsWithFetchSpecification > objects=3Dself.parentObjectStore().objectsWithFetchSpecification(fs,= =20 > ec) > File "C:\PROGRA~1\Zope2.6.2\bin\Modeling\ObjectStoreCoordinator.py", = =20 > line > 434, in objectsWithFetchSpecification > return store.objectsWithFetchSpecification(aFetchSpecification, > anEditingContext) > File "C:\PROGRA~1\Zope2.6.2\bin\Modeling\DatabaseContext.py", line =20= > 1817, > in objectsWithFetchSpecification > anEditingContext) > File "C:\PROGRA~1\Zope2.6.2\bin\Modeling\DatabaseChannel.py", line =20= > 394, in > selectObjectsWithFetchSpecification > entity) > File > = "C:\PROGRA~1\Zope2.6.2\bin\Modeling\DatabaseAdaptors\AbstractDBAPI2Adap=20= > torLa > yer\AbstractDBAPI2AdaptorChannel.py", line 297, in selectAttributes > raise GeneralAdaptorException, msg > Modeling.Adaptor.GeneralAdaptorException: Couldn't evaluate expression > SELECT DISTINCT t0.KLASA_ID, t0.NAZWA, t0.PROFIL, t0.WYCHOWAWCA_ID = FROM > KLASA t0 INNER JO > IN NAUCZYCIEL t1 ON t0.WYCHOWAWCA_ID=3Dt1.NAUCZYCIEL_ID WHERE > t1.DATA_URODZENIA > '1970'. Reason: libpq.OperationalError:ERROR: Bad > timestamp external representation '1970' > ------------------------------------ > > Is there any explanation? > > > **************************** > * =A3ukasz =A3akomy > * luk...@po... > **************************** > > > > > ------------------------------------------------------- > This SF.net email is sponsored by: SF.net Giveback Program. > Does SourceForge.net help you be more productive? Does it > help you create better code? SHARE THE LOVE, and help us help > YOU! Click Here: http://sourceforge.net/donate/ > _______________________________________________ > Modeling-users mailing list > Mod...@li... > https://lists.sourceforge.net/lists/listinfo/modeling-users |