Page 1 of 1

Milliseconds precision, test fail

Posted: 11.10.2011, 16:23
by papelhigienico
I did a change to support the milliseconds precision with certain databases like postgres and sqlite. But after this, running the tests, I got:

TIME() failed, expected: <1899-12-30 12:17:34> but was: <1899-12-30 12:17:34.465>

on

TZTestExpressionCase -> TestFunctionsDateTime

Now, I don't know if my change is wrong or if the test is wrong... Ideas?

Posted: 11.10.2011, 17:53
by seawolf
I think you changed the interface, so you need to change also the test.

I mean correctly that test fail because in one case millisecond are filtered, while in the other not.

Posted: 11.10.2011, 18:49
by papelhigienico
Test fails at line 186 of ZTestExpression.pas

Expression := 'TIME()';
CheckEquals(FormatDateTime('yyyy-mm-dd hh":"nn":"ss',Time), SoftVarManager.GetAsString(Evaluate),Expression+' failed, ');


I changed two functions at ZSysUtils.pas

function AnsiSQLDateToDateTime(const Value: string): TDateTime; (values from DB to application)

and

function DateTimeToAnsiSQLDate(Value: TDateTime): string; (values from application to database)

So, I undid the changes in DateTimeToAnsiSQLDate and everything are ok on test. But, if a date/time value (with milliseconds) is inserted via a TZTable, the milliseconds are lost.

So, I thought that the best way to insert a date time value with milliseconds is doing your own Insert query. Maybe I'm wrong. Ideas?

I searched and the SQL-92 standard says nothing about milliseconds.