synopse / mORMot

Synopse mORMot 1 ORM/SOA/MVC framework - Please upgrade to mORMot 2 !
https://synopse.info
788 stars 325 forks source link

BatchSend mistakenly strips off millisecond part of TDateTimeMS #397

Closed wxinix closed 3 years ago

wxinix commented 3 years ago

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);
        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 issue.

Can you please double check? Thanks.

wxinix commented 3 years ago

The fix works. Thank you very much.