#1 Re: mORMot 2 » TDocVariantData Range check error » 2024-05-14 16:33:43

Hi

Is this the correct method to delete the object/objects?

  for AObj in AList.Objects(LCompareStr) do
    AList.Remove(AObj.AsVariant);

#2 Re: mORMot 2 » TDocVariantData Range check error » 2024-05-13 11:37:54

I want to do something like below. I did what I wanted manually with the loop. Thanks.

IDocList.Objects('name LIKE test%')
or
IDocList.Objects('name', '%test%', coLike)
or
IDocList.Objects('name', 'test', coInclude)
or
IDocList.Objects('name', 'test', coStartsWith)
or
IDocList.Objects('name', 'test', coEndsWith)

#3 Re: mORMot 2 » TDocVariantData Range check error » 2024-05-13 09:19:45

I started using "IDocList/IDocObject". How can I do custom filtering using TVariantCompare? Are there any examples? I need to make a comparison like "startsWith/endsWith" or "%like%".

#4 mORMot 2 » URL encoded form parameters parsing » 2024-05-12 07:50:28

nakisen
Replies: 1

I need to parse the following encoded form values. I use the "UrlDecodeNextNameValue" function for this. However, the result is as follows;

  //original decoded value
  name "time >="  value "1715497685"

  //encoded form value
  time%20%3C%3D=1715497685

  // UrlDecodeNextNameValue(time%20%3C%3D=1715497685) result
  // name "time >"    value "=1715497685"
  
  // Expected
  // name "time >="    value "1715497685"

Does the UrlDecodeNextName() function return an expected value? Will the following change cause different problems?

// mormot.core.buffers 
// Line 8290 has been changed
...
      #0:
        exit;
      '=':
        begin
          result := U + 1;
          break;
        end;
      '%':
        if HexToCharValid(pointer(U + 1) {$ifndef CPUX86NOTPIC}, tab{$endif}) then
          inc(U, 3)
        else
          inc(U);
...

#5 Re: mORMot 2 » TDocVariantData Range check error » 2024-05-12 06:16:03

I did initialization and everything is fine roll smile

  LObj.Init;

#6 Re: mORMot 2 » TDocVariantData Range check error » 2024-05-11 21:54:53

Interestingly, even though I haven't made any changes in the code, sometimes I get the "Range check error" error and sometimes the "Add: Unexpected [id] object property in an array" error.

Compiler/IDE: Delphi 12.

#7 mORMot 2 » TDocVariantData Range check error » 2024-05-11 21:18:44

nakisen
Replies: 8

Hi

I'm getting an error when working with TDocVariantData.

// This code works
procedure TForm1.Button3Click(Sender: TObject);
var
  LObj:TDocVariantData;
  LKey, LValue:Utf8String;
begin
  LKey:='id';
  LValue:='1001-test;@6f2dcdcc4303a085a18d98419e1fb374';
  LObj.AddValue(LKey, LValue);

  LKey:='id2';
  LValue:='50';
  LObj.AddValue(LKey, LValue);

  memo1.Lines.Add(LObj.ToJson);
end;
// This code is not working
procedure TForm1.Button2Click(Sender: TObject);
var
  LObj:TDocVariantData;
begin
  FillParams(PUtf8Char(FParamStr), LObj);
  memo1.Lines.Add(LObj.ToJson);
end;

procedure FillParams(AParams:PUtf8Char; var AObj:TDocVariantData);
var
  LKey, LValue:Utf8String;
begin

  if (AParams = nil) then exit;

  repeat
    AParams := UrlDecodeNextNameValue(AParams, LKey, LValue);
    // Lkey='id', LValue='1001-test;@6f2dcdcc4303a085a18d98419e1fb374'
    AObj.AddValue(LKey, LValue);  <--- Range check error

    if AParams = nil then  break;
  until AParams^ = #0;

end;

Why am I getting this error? Am I missing something?

#8 mORMot 2 » Saving the archive log file as zip » 2024-01-08 16:58:56

nakisen
Replies: 2

Hi

I want to save the log file to be archived as a zip. But it keeps saving as "synlz".

  with TSynLog.Family do
    begin
      //AutoFlushTimeOut:=10;
      RotateFileCount:=100;
      RotateFileSizeKB:=20; //test size
      Level := LOG_VERBOSE;
      PerThreadLog := ptIdentifiedInOnFile;
      EchoToConsole := LOG_VERBOSE;
      FileExistsAction:=acAppend;
      CustomFileName:='project_test';
      OnArchive:=mormot.core.zip.EventArchiveZip;
    end;
// mormot.core.zip

function EventArchiveZip(const aOldLogFileName, aDestinationPath: TFileName): boolean;
var
  n: integer;
begin
  result := false;
  if aOldLogFileName = '' then   <<<  This function fired but, "aOldLogFileName" is empty string.
    FreeAndNilSafe(EventArchiveZipWrite)
  else
  begin
    if not FileExists(aOldLogFileName) then
      exit;
    if EventArchiveZipWrite = nil then
      EventArchiveZipWrite := TZipWrite.CreateFrom(
        copy(aDestinationPath, 1, length(aDestinationPath) - 1) + '.zip');
    n := EventArchiveZipWrite.Count;
    EventArchiveZipWrite.AddDeflated(aOldLogFileName, {removepath=}true);
    if (EventArchiveZipWrite.Count = n + 1) and
       DeleteFile(aOldLogFileName) then
      result := true;
  end;
end;

#9 Re: mORMot 2 » Simple testing without using ORM » 2024-01-07 22:17:58

First of all, you did a great job. Thanks again.

Like you, I think some structures should be simplified. For those new to mORMot, the learning curve should be rapid. After learning mORMot, I would like to contribute.

//I think these types of regulations you are talking about are;

FHttpServer:TContainerHttpServer;	// or TAppHttpServer
FRestApp:TRestHttpApplication;		// or TRestHttpService
FRawApp:TRawHttpAppication;		// or TRawHttpService
FMvcApp:TMvcHttpApplication;		// or TMvcHttpService
	
FHttpServer.Create('0.0.0.0:80', [FRestApp, FRawApp]);

FRestApp.Root:='/api';
FRestApp.Storage:=TOrmModel;
//FRestApp.Storage:=TMemoryModel;

FRawApp.Root:='/';
FRawApp.StaticsPath:='/statics'

#10 Re: mORMot 2 » Simple testing without using ORM » 2024-01-07 15:58:21

I had already realized that I needed to use TRestServerFullMemory after your message. Thanks

#11 Re: mORMot 2 » Simple testing without using ORM » 2024-01-07 14:22:45

Thanks ab :$

I want to get rid of SQL, so I'll use ORM smile

#12 mORMot 2 » Simple testing without using ORM » 2024-01-06 23:14:51

nakisen
Replies: 7

Hello

I wanted to do a simple test without using any ORM instance, but I'm getting an "Access Violation" error. What am I missing?

mormot.rest.core.pas

procedure TRest.OnBeginCurrentThread(Sender: TThread);
begin
  fOrmInstance.BeginCurrentThread(Sender);  <<< fOrmInstance has not been created; Access Violation
end;
...
type
  TSampleServer = class(TRestServer)
  published
    procedure test(Ctxt: TRestServerUriContext);
  end;
...
FApiServer:TSampleServer;
FHttpServer:TRestHttpServer;
...
procedure TForm1.FormCreate(Sender: TObject);
begin
  FApiServer:=TSampleServer.Create('api');

  FHttpServer := TRestHttpServer.Create('80', [FApiServer], '+', HTTP_DEFAULT_MODE, 4);
  FHttpServer.AccessControlAllowOrigin := '*';
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  FHttpServer.Free;
  FApiServer.Free;
end;

procedure TSampleServer.test(Ctxt: TRestServerUriContext);
begin
  Ctxt.Returns('{"result":null}');
end;

#13 Re: mORMot 1 » Delphi Linux support » 2021-05-02 19:34:33

macfly wrote:

But when I started using Lazarus more deeply this changed.

Some links that may be of interest to you

I have been developing Linux Daemons with lazarus since 2013. I know all the information you have specified.

I did not know about LazDebuggerFp. I will try.

Thanks.

#14 Re: mORMot 1 » Delphi Linux support » 2021-04-30 20:29:48

I tested Linux applications compiled in Delphi on CentOS7 and CentOS8. I did not have any problems. I have not had experience with different Linux distributions.

#15 Re: mORMot 1 » Delphi Linux support » 2021-04-30 17:22:03

For a long time, I have been developing small services that run on Linux. I use FPC and Lazarus IDE to develop these services. The only IDE to be used with FPC is Lazarus. However, I think Delphi IDE is more comfortable than Lazarus at a few points.

I hope you add Delphi Linux support to your roadmap.

#16 mORMot 1 » Delphi Linux support » 2021-04-30 12:26:52

nakisen
Replies: 8

I'm new to mORMot. Framework looks great! Congratulations on your work. Do you have a plan for Delphi Linux64 support?

Board footer

Powered by FluxBB