#1 mORMot 1 » Mormot2 WebSocket » 2022-12-17 05:54:48

Ghiber
Replies: 1

hi, i have a server THttpApiWebSocketServer which works very well on the web, i am now trying to do a test with a windows client, when i use mormot 1 TWinHttpWebSocketClient.Create('localhost','8087',false,'socket',' ') all good but this same line in mormot 2 generates an error: the connection to the server ended abnormally, am I missing something?

#2 Re: mORMot 1 » error creating json » 2021-12-11 19:20:30

ab, sorry I already found the line that makes it work differently than what I expected,
here I show how it was before and how it is now, this change was made in one of your fixes.

function TDocVariantData.InternalAdd(const aName: RawUTF8): integer;
var len: integer;
begin
  if aName<>'' then begin
    if dvoIsArray in VOptions then
      raise EDocVariant.CreateUTF8('Add: Unexpected [%] object property in an array',[aName]);
    if not(dvoIsObject in VOptions) then begin
      VType := DocVariantVType; // may not be set yet
      include(VOptions,dvoIsObject);
    end;
  end else begin
    if dvoIsObject in VOptions then
      raise EDocVariant.Create('Add: Unexpected array item in an object');
    if not(dvoIsArray in VOptions) then begin
      VType := DocVariantVType; // may not be set yet
      include(VOptions,dvoIsArray);
    end;
  end;

********************************NOT WORK actual version mormot ************************
//  len := length(VValue);
//  if VCount>=len then begin
//    len := NextGrow(VCount);
//    SetLength(VValue,len);
//  end;
//  if aName<>'' then begin
******************************************************************



*************IT WORKS  previous version mormot*******************
  if VValue=nil then
    SetLength(VValue,16) else
    if VCount>=length(VValue) then
      SetLength(VValue,VCount+VCount shr 3+32);
  if aName<>'' then begin
    len := length(VValue);

*****************************************



    if Length(VName)<>len then
      SetLength(VName,len);
    if dvoInternNames in VOptions then begin // inlined InternNames method
      if DocVariantType.fInternNames=nil then
        DocVariantType.fInternNames := TRawUTF8Interning.Create;
      DocVariantType.fInternNames.Unique(VName[VCount],aName);
    end else
      VName[VCount] := aName;
  end;
  result := VCount;
  inc(VCount);
end;

#3 Re: mORMot 1 » error creating json » 2021-12-11 13:44:09

Thanks for your prompt response, I understand your answer and I had already done the test by using indexes, if it works, the strange thing is that I change the mormot to a previous version and if it works, but well I'll change it to work with indexes, and how the project is quite long I'm afraid I must check carefully, but I repeat before it worked.

#4 mORMot 1 » error creating json » 2021-12-11 13:21:20

Ghiber
Replies: 5

hello, I have created a small example to be able to generate demonstrate the error, before it worked in previous versions of mormot something happens now

Var
 Main:TDocVariantData;
 PArray1,PArray2,PArray3:PDocVariantData;



begin
  Main.Init();

  Main.AddValue('value0',10);

  Main.AddValue('object',_Obj([]));

  PArray1:=Main._[Main.AddValue('array1',_Arr([]))];
  PArray2:=Main._[Main.AddValue('array2',_Arr([]))];
  PArray3:=Main._[Main.AddValue('array3',_Arr([]))];

  PArray3.AddItem(_Obj(['value3',30]));
  PArray2.AddItem(_Obj(['value2',20]));
  PArray1.AddItem(_Obj(['value1',10]));

  writeln(Main.ToJSON());
  readln;
end.

the correct result expected in earlier versions of mormot 1 is this


{"value0": 10, "object": {}, "array1": [{"value1": 10}], "array2": [{"value2" : 20}], "array3": [{"value3": 30}]}


now in the latest version of mormot 1 is this


{"value0":10,"object":{},"array1":[],"array2":[],"array3":[{"value3":30}]}

#5 Re: mORMot 1 » Problem with SynDBSQLite3 » 2018-03-17 17:48:29

thank you very much. Excellent

#6 mORMot 1 » Problem with SynDBSQLite3 » 2018-03-12 16:59:31

Ghiber
Replies: 2

hello ab,
I have been migrating a large project which used ADO components to mormot, as a very large one, I decided for the moment to use the TQuery class of unit SynDB with which I have done very well and in the future to use interfaces, so I have managed to get my software used db oracle database, sqlserver, postgre, mysql, of course I had to standardize the sql statements, but nevertheless it was easy and fast, but I had a problem when I wanted to use sqlite database, the behavior of the TQuery.First method fails and however with the other databases mentioned above it is not, debugging I have noticed that most of the SynOleDB, SynDBZeos, SynDBODBC units at some time before or after executing a new statement initialize the property fCurrentRow: = -1 or fCurrentRow: = 0
but the SynDBSQLite3 unit does not at any time, there is some reason in particular, since when I initialized the property by modifying the sources


procedure TSQLDBSQLite3Statement.ExecutePrepared;
var SQLToBeLogged: RawUTF8;
    Timer: TPrecisionTimer;
    DB: TSQLDataBase;
begin
  fCurrentRow:=0; /////CHANGE HERE/////
  inherited ExecutePrepared; // set fConnection.fLastAccessTicks

I would like to know if I make that change in the sources I will not have problems in the future thanks.

#7 Re: mORMot 1 » Suggestion for SynDBMidasVCL unit » 2018-02-22 20:01:59

ok thank you very much I will try it

#8 mORMot 1 » Suggestion for SynDBMidasVCL unit » 2018-02-22 17:52:39

Ghiber
Replies: 2

Hello, I am trying to implement the mormot unit with a third-party component called Digital-metaphor Reportbuilder, this has a feature that can be seen here: http://www.digital-metaphors.com:8080/D … DE_Plugins to add other database manager, and I'm working well but I had to make a small change to the sources, since I want this to work with several databases, the problem is that the reporbuilder needs to update some tables and I am using TSynDBDataSet that allows me to apply changes in the tables, this is all fine but when the tables are blank the TSynDBDataSet the ColumnDataSize calculation is wrong and if I use IgnoreColumnDataSize it works as a memo field even worse since reporbuilder is stricter with the definition of the table, for that reason make some changes so that the user that create a ClientDataSet with TSynDBDataSet is the one that decides how is the definition of the table and not the same mormot, being able to achieve something like this:

 DataClient:=TSynDBDataSet.Create(nil);
 DataClient.CommandText:='SELECT FOLDERID,FOLDERNAME,PARENTID FROM FOLDERS';
 Ds1.DataSet:=DataClient;
 DataClient.Connection:=FProp;
 DataClient.OwnerDef:=True;  // MY PROPERTY
   with DataClient.FieldDefs do
   begin
     Clear;
      Add('folderid',ftLargeint, 0);
      Add('foldername',ftWideString, 60);
      Add('parentid',ftLargeint);
    end;
 DataClient.Open;

the change I made in the unit SynDBVCL procedure InternalInitFieldDefs

procedure TSynBinaryDataSet.InternalInitFieldDefs;
var F: integer;
    DBType: TFieldType;
    S:String;
    N:Integer;
begin
  FieldDefs.Clear;

  ****************ADD*************
  if (Owner is TSynDBDataSet) then begin
    if TSynDBDataSet((Self).Owner).OwnerDef then begin   //property add  OwnerDef
      with TSynDBDataSet((Self).Owner) do begin
        for F := 0 to FieldDefList.Count-1 Do
          TSynBinaryDataSet(Self).FieldDefs.Add(FieldDefList[F].Name,FieldDefList[F].DataType,FieldDefList[F].Size);
      End;
    exit;
    end
  end;
*************************************

  if fDataAccess=nil then
    exit;
  for F := 0 to fDataAccess.ColumnCount-1 do
    with  fDataAccess.Columns[F] do begin
    case ColumnType of
    SynCommons.ftInt64: DBType := ftLargeint;
    SynCommons.ftDate:  DBType := ftDateTime;
    SynCommons.ftUTF8:  DBType := ftWideString; // means UnicodeString for Delphi 2009+
    SynCommons.ftBlob:  DBType := ftBlob;
    SynCommons.ftDouble, SynCommons.ftCurrency: DBType := ftFloat;
    else raise EDatabaseError.CreateFmt(
      'GetFieldData ColumnType=%s',[TSQLDBFieldTypeToString(ColumnType)]);
    end;
    FieldDefs.Add(UTF8ToString(ColumnName),DBType,ColumnValueDBSize);
  end;
end;

Any suggestion that you can do this in another way thanks.

#9 mORMot 1 » Problem creating a TDocVariantArrayDataSet dataset » 2018-02-21 03:49:48

Ghiber
Replies: 0

Hello, I'm having problems doing some tests like in example 17 TClientDatase something like that

fJSON:='[{"Id":"1","Name":"Ghiber","DateTime":"2018-02-20T19:22:51"}]'

values.InitJSON(fJSON,JSON_OPTIONS[true]);

ds1.DataSet := ToDataSet(self,values.Values,['Id','Name','DateTime'],[ftInt64,ftUTF8,ftDate]);

the date generated in the dataset is null.
debugging I found that the SynVirtualDataSet unit exists a function called TDocVariantArrayDataSet.GetRowFieldData which has a condition

case fColumns [F] .FieldType of
           ftDouble, SynCommons.ftDate:
             VariantToDouble (Values [ndx], PDouble (@ fTemp64) ^

there would be the possibility that this variant is processed something like this

           SynCommons.ftDate:
             VariantToDateTime (Values [ndx], PDateTime (@ fTemp64) ^);

note: this line generates the date well but not the time

in the mormot documentation explains that this class TDocVariantArrayDataSet is used for mongodb can generate a VCL dataset, but there is the
possibility of creating a property where it indicates that the TVariantDynArray is generated from another source as explained in example 17

#10 Re: mORMot 1 » SynVirtualDataSet unit problem » 2018-02-10 16:13:19

ok perfect, thanks for the fix, this solves the problem when the date is null

#11 mORMot 1 » SynVirtualDataSet unit problem » 2018-02-10 04:18:51

Ghiber
Replies: 2

Hello, in this unit there is a function called

TSynVirtualDataSet.GetFieldData in which a line was written like this

result: = Data <> nil; // null field or out-of-range RowIndex / Field

assuming that at some point the Data variable can be Nil

but below in the same function is the line when the field is type:  ftDate, ftTime, ftDateTime

if PDateTime (Data) ^ = 0 then

when the data is Nil then it would be something like that

if PDateTime (Nil) ^ = 0 then

generating an error the compiler
  and the condition is never met

#12 Re: mORMot 1 » Problem with Fmx Client using Execute SQL via services » 2017-12-14 22:13:43

Thank you very much for the help, now solve, everything was in the procedure ConsoleWaitForEnterKey both the loop with the function CheckSynchronize. I already have running the example 16 in windows, linux, android.

#13 Re: mORMot 1 » Problem with Fmx Client using Execute SQL via services » 2017-12-14 14:05:03

ok thank you I will try, and congratulations for your great framework

#14 mORMot 1 » Problem with Fmx Client using Execute SQL via services » 2017-12-14 05:41:01

Ghiber
Replies: 4

Hi, I'm trying to implement the Samples \ 16 - Execute SQL via services for a cross-platform client in delphi fmx, works fine without using

.SetOptions ([], [optExecInMainThread, optFreeInMainThread]) on the server, trying not to generate a new connection to the sqlserver every time I run a query on the client side, but when I use optExecInMainThread, calls to the methods from The client does not work, What am I doing wrong. Thank you.

Board footer

Powered by FluxBB