#2 mORMot 1 » AsTSQLRecord Error:Incompatible types: got "Pointer" expected "TTable" » 2020-11-30 06:30:41

matrix1233
Replies: 2

Hi,
I have a problem with mormot and Lazarus, so XX.AsTSQLRecord it work perfectly on Delphi but when i try to use the same code on lazarus i have this message : Error: Incompatible types: got "Pointer" expected "TNoteCase". I used a simple code that i have copied from https://tamingthemormot.wordpress.com/tag/mormot/ .
So can you help me to resolve this problem ? Thanks

unit NoteORM;
interface

uses Classes, SynCommons, mORMot;

type
  TNoteCase = class(TSQLRecord)
  private
    FDescription: RawUTF8;
  published
    property Description: RawUTF8 read FDescription write FDescription;
  end;

  TNote = class(TSQLRecord)
  private
    FBody: RawUTF8;
    FTitle: RawUTF8;
    FNoteCase: TNoteCase;
  published
    property NoteCase: TNoteCase read FNoteCase write FNoteCase;
    property Body: RawUTF8 read FBody write FBody;
    property Title: RawUTF8 index 80 read FTitle write FTitle;
  end;

implementation

end.         
var
  Form1: TForm1;
  Database: TSQLRest;
  Model: TSQLModel;

implementation

{$R *.lfm}
procedure Tform1.TestIt(rest:TSQLRest);
var
  aCase : NoteORM.TNoteCase;
  aNote : NoteORM.TNote;
begin
  aCase := NoteORM.TNoteCase.Create;
  try
    aCase.Description := 'Case 1';
    rest.Add( aCase, true );
    aNote := NoteORM.TNote.Create;
    try
      aNote.Title := 'Note 1';
      aNote.Body  := 'Note 1 body. Lots of other stuff too.';
      aNote.NoteCase := aCase.AsTSQLRecord ;   // here  it's work with delphi but doesn't work with lazarus 
      rest.Add( aNote, true );

      aNote.Title := 'Note 2';
      aNote.Body  := 'Note 2 body. Lots of other stuff too. Some more things here.';
      rest.Add( aNote, true );
    finally
      aNote.Free;
    end;
  finally
    aCase.Free;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
   Model    := TSQLModel.Create([TNoteCase,TNote]);
   Database := TSQLRestServerDB.Create(Model,ChangeFileExt(paramstr(0),'.db3'));
   TSQLRestServerDB(Database).CreateMissingTables;
   TestIt(Database);
end;           

Board footer

Powered by FluxBB