#1 2021-05-09 01:36:06

wxinix
Member
Registered: 2020-09-07
Posts: 121

BatchSend mistakenly strips off millisecond part of TDateTimeMS

TDateTimeMS type is supposed to have a millisecond part, when adding to an external database (e.g., PostgreSQL).

It works as expected if the record is added individually using the Add method.

Howerver, when BatchAdd, mORMot will mistakenly strip off the millisecond part of TDateTimeMS field inside method TSQLDBStatementWithParams.BindArray, Line 7891-7896, of SynDB.pas:

if (ParamType=ftDate) and (ChangeFirstChar<>'T') then
    for i := 0 to ValuesCount-1 do // fix e.g. for PostgreSQL
      if (p^.VArray[i]<>'') and (p^.VArray[i][1]='''') then begin
        v.From(PUTF8Char(pointer(p^.VArray[i]))+1,length(p^.VArray[i])-2);  // <<---  This line would strip off the millisecond part?
        p^.VArray[i] := v.FullText({expanded=}true,ChangeFirstChar,'''');
      end;

I also checked the mORMot-generated SQL query sent to the database engine, which confirmed the above.

Can you please double check? Thanks.

Last edited by wxinix (2021-05-09 01:37:37)

Offline

#2 2021-05-09 10:32:36

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,548
Website

Re: BatchSend mistakenly strips off millisecond part of TDateTimeMS

Which provider (SynDB properties class) are you using?

Please try my latest patch on trunk.

Offline

#3 2021-05-09 11:29:29

wxinix
Member
Registered: 2020-09-07
Posts: 121

Re: BatchSend mistakenly strips off millisecond part of TDateTimeMS

ab wrote:

Which provider (SynDB properties class) are you using?

Please try my latest patch on trunk.

I use PostgresSQL. TSQLDBZEOSConnectionProperties

Thank you very much.  The latest patch works!

Offline

Board footer

Powered by FluxBB