Re: [Modeling-users] Strange date conversion in fetch qualifier
Status: Abandoned
Brought to you by:
sbigaret
|
From: Mario R. <ma...@ru...> - 2003-12-04 05:59:33
|
> Mario Ruggier <ma...@ru...> wrote:
>> [...]
>> 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 = 'createdate=="%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.
>
> This would help if you had a working test case, yes ;)
Fair enough ;)
I have made a simple object with just a DateTime attribute,
so in the pymodel it looks like :
Entity('MyObj',
properties=[
ADateTime('createdate',displayLabel='Date',isRequired=1),
]
)
Then I made the following test that uses it:
def test_0_FetchUnSavedDateTime(self):
ec = EditingContext()
o = MyObj()
test_datetime = mx.DateTime.now()
q = 'createdate=="%s"' %(test_datetime)
o.setCreatedate(test_datetime)
ec.insert(o)
ec.saveChanges()
print test_datetime,
print ec.fetch('MyObj',qualifier=q)[0]
o2 = MyObj()
test_datetime2 = mx.DateTime.now()
q2 = 'createdate=="%s"' %(test_datetime2)
o2.setCreatedate(test_datetime2)
ec.insert(o2)
#ec.saveChanges()
print test_datetime2,
print ec.fetch('MyObj',qualifier=q2)[0]
The first fetch is OK, the second is not.
This is with SQLite and Modleing CVS.
Cheers, mario
|