#1 2020-05-29 06:48:57

Vitaly
Member
From: UAE
Registered: 2017-01-31
Posts: 168
Website

a trouble with TSQLRecord.FillOne/FillRow and FB TIME field

[Delphi 10.4/10.3.3, Win64 target, Zeos, FB 2.5.9]

Currently, I have a trouble with one of my old projects, using legacy FB DB and TIME field in a table (TDateTime in TSQLRecord). All worked fine before, but suddenly I noticed, that TSQLRecord.FillOne fills this field with value 0 - always.

I tried to find the commit, where the change has happened in mORMot and Zeos repos, but failed.
Then I tried to debug and found that TSQLPropInfoRTTIDateTime.SetValue retrieves a shortened value, like 'T08:00:0' (without last digit). Therefore it seemed to me that Iso8601ToDateTimePUTF8CharVar counts the result incorrectly (due to highly incorrect SS value).

Is there some bug, or is it something wrong with my code?

Offline

#2 2020-05-29 07:53:26

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

Re: a trouble with TSQLRecord.FillOne/FillRow and FB TIME field

I guess 'T08:00:0' is invalid, and should not be converted.
So the problem seems not in TSQLPropInfoRTTIDateTime.SetValue / Iso8601ToDateTimePUTF8CharVar but before that, when it is retrieved from the DB.

Could you investigate a little further and check why 'T08:00:0' is returned from the DB? It should not.

Offline

#3 2020-05-29 09:42:42

Vitaly
Member
From: UAE
Registered: 2017-01-31
Posts: 168
Website

Re: a trouble with TSQLRecord.FillOne/FillRow and FB TIME field

well, I continued the investigation, and when I got to SynDBZeos.TSQLDBZEOSStatement.ColumnsToJSON procedure, I noticed there

  {$if defined(ZEOS73UP) and defined(USE_SYNCOMMONS)}
  fResultSet.ColumnsToJSON(WR,fJSONComposeOptions);
  {$else}
  ...

And since I have USE_SYNCOMMONS definition in all mORMot+Zeos projects according to @EgonHugeist recommendation, this code is running.
I tried to rebuild the project without USE_SYNCOMMONS, and all worked as intended.
That's why I couldn't find the particular change in mORMot and Zeos repos smile
So, I guess, the problem is somewhere in fResultSet.ColumnsToJSON, which launches with USE_SYNCOMMONS. Does it help somehow, or I should go deeper?

Last edited by Vitaly (2020-05-29 09:43:33)

Offline

#4 2020-05-29 11:24:58

Vitaly
Member
From: UAE
Registered: 2017-01-31
Posts: 168
Website

Re: a trouble with TSQLRecord.FillOne/FillRow and FB TIME field

ok, probably, I've found the typo in ZDbcFirebirdInterbase.pas (latest Zeos git-master commit, line 1678, TZAbstractInterbaseFirebirdResultSet.ColumnsToJSON procedure):

JSONWriter.AddNoJSONEscape(@FTinyBuffer[0],8+(4*Ord(jcoMilliseconds in JSONComposeOptions))); 

I assume there should be 9 instead of 8: THH:MM:SS.
If I change it to

JSONWriter.AddNoJSONEscape(@FTinyBuffer[0],9+(4*Ord(jcoMilliseconds in JSONComposeOptions))); 

it works fine with USE_SYNCOMMONS

Offline

#5 2020-05-29 15:39:13

EgonHugeist
Member
From: Germany
Registered: 2013-02-15
Posts: 190

Re: a trouble with TSQLRecord.FillOne/FillRow and FB TIME field

Hello vitaly,

i'm sorry for that regression. I just didn't count the 'T' delimiter in my mind. Other drivers had the same mistake(copy+paste issue), so i fixed them all. Plz update from SVN. Regression gone?
Michael

Offline

#6 2020-05-29 17:06:26

Vitaly
Member
From: UAE
Registered: 2017-01-31
Posts: 168
Website

Re: a trouble with TSQLRecord.FillOne/FillRow and FB TIME field

Hi Michael! Yes, with [r6577] almost all works fine. Thank you! smile

Could you only make a couple of additional tiny fixes (or it won't compile):

ZDbcMySqlResultSet.pas, line 508. Missing closing bracket. Fixed line:

JSONWriter.AddNoJSONEscape(PUTF8Char(FByteBuffer),9+(4*Ord(jcoMilliseconds in JSONComposeOptions)));

ZDbcOracleResultSet.pas, line 500. Excess closing bracket. Fixed line:

JSONWriter.AddNoJSONEscape(PUTF8Char(fByteBuffer),9);

Offline

#7 2020-05-29 19:38:52

EgonHugeist
Member
From: Germany
Registered: 2013-02-15
Posts: 190

Re: a trouble with TSQLRecord.FillOne/FillRow and FB TIME field

Offline

#8 2020-05-29 20:16:28

Vitaly
Member
From: UAE
Registered: 2017-01-31
Posts: 168
Website

Re: a trouble with TSQLRecord.FillOne/FillRow and FB TIME field

Nice, thanks! smile

Offline

Board footer

Powered by FluxBB