#1 2021-04-08 14:31:25

itSDS
Member
From: Germany
Registered: 2014-04-24
Posts: 516

mORMot2 Wrapper generation broken

Hi Arnaud, i generated a soa interface for a new service and created the CrossPlatform Wrappers for an app.
But the generated pas - Sourcecode ist broken. I send you an example via EMail.


Rad Studio 12.1 Santorini

Offline

#2 2021-04-08 14:34:57

itSDS
Member
From: Germany
Registered: 2014-04-24
Posts: 516

Re: mORMot2 Wrapper generation broken

Example from mORMot2

unit mORMotClient;

{
  WARNING:
    This unit has been generated by a mORMot 2.0.1 server.
    Any manual modification of this file may be lost after regeneration.

  Synopse mORMot framework. Copyright (C) 2021 Arnaud Bouchez
    Synopse Informatique - http://synopse.info

  This unit is released under a MPL/GPL/LGPL tri-license,
  and therefore may be freely included in any application.

  This unit would work on Delphi 6 and later, under all supported platforms
  (including MacOSX, and NextGen iPhone/iPad), and the Free Pascal Compiler.
}

interface

uses
  SynCrossPlatformJSON,
  SynCrossPlatformSpecific,
  SynCrossPlatformREST;
  

type // define some enumeration types, used below
  TPeopleSexe = (sFemale, sMale);

type // define some record types, used as properties below
  TresultRec = record
      erfolgJN: String;
      fehlertext: String;
      hinweistext: String;
  end;

  00e21f50 = record
        H3a: Boolean;
        H3b: RawBlob;
  end;

  00e21ea0 = record
      H1: Integer;
      H2: String;
      H3: 00e21f50;record
        H3a: Boolean;
        H3b: RawBlob;
      end;
  end;

  TTestCustomJSONArraySimpleArray = record
    F: String;
    F1: TresultRec;record
      erfolgJN: String;
      fehlertext: String;
      hinweistext: String;
    end;
    G: RawBlob;
    H: 00e21ea0;record
      H1: Integer;
      H2: String;
      H3: 00e21f50;record
        H3a: Boolean;
        H3b: RawBlob;
      end;
    end;
    I: TDateTime;
    J: RawBlob;
  end;

  00e213a0 = record
      erfolgJN: String;
      fehlertext: String;
      hinweistext: String;
  end;

Rad Studio 12.1 Santorini

Offline

#3 2021-04-08 14:37:03

itSDS
Member
From: Germany
Registered: 2014-04-24
Posts: 516

Re: mORMot2 Wrapper generation broken

Same Code with mORMot

unit mORMotClient;

{
  WARNING:
    This unit has been generated by a mORMot 1.18.6262 server.
    Any manual modification of this file may be lost after regeneration.

  Synopse mORMot framework. Copyright (C) 2021 Arnaud Bouchez
    Synopse Informatique - http://synopse.info

  This unit is released under a MPL/GPL/LGPL tri-license,
  and therefore may be freely included in any application.

  This unit would work on Delphi 6 and later, under all supported platforms
  (including MacOSX, and NextGen iPhone/iPad), and the Free Pascal Compiler.
}

interface

uses
  SynCrossPlatformJSON,
  SynCrossPlatformSpecific,
  SynCrossPlatformREST;
  

type // define some enumeration types, used below
  TPeopleSexe = (sFemale, sMale);
  TRecordEnum = (reOne, reTwo, reLast);

type // define some record types, used as properties below
  TresultRec = record
    erfolgJN: String;
    fehlertext: String;
    hinweistext: String;
  end;

  TTestCustomJSONArraySimpleArray = record
    F: String;
    F1: TresultRec;
    G: array of String;
    H: record
      H1: Integer;
      H2: String;
      H3: record
        H3a: Boolean;
        H3b: TSQLRawBlob;
      end;
    end;
    I: TDateTime;
    J: array of record
      J1: Byte;
      J2: TGUID;
      J3: TRecordEnum;
    end;
  end;

  TResultRecord = record
    resultRec: record
      erfolgJN: String;
      fehlertext: String;
      hinweistext: String;
    end;
    FResult1: String;
    FResult2: String;
    FResult3: String;
    FResult4: String;
  end;

  TSimpleRecord = record
    A: Integer;
    B: Integer;
    C: String;
  end;

Rad Studio 12.1 Santorini

Offline

#4 2021-04-08 14:51:24

itSDS
Member
From: Germany
Registered: 2014-04-24
Posts: 516

Re: mORMot2 Wrapper generation broken

If i generate the Wrapper with mORMot and the SOA Service with mORMot2 it works smile


Rad Studio 12.1 Santorini

Offline

#5 2021-04-09 07:34:25

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

Re: mORMot2 Wrapper generation broken

I didn't test the wrapper generator yet.
It changed because the RTTI changed...

Have you some fixes proposals?

Offline

#6 2021-04-09 09:47:35

itSDS
Member
From: Germany
Registered: 2014-04-24
Posts: 516

Re: mORMot2 Wrapper generation broken

i didn't dig in the deep - yet. No proposals atm.


Rad Studio 12.1 Santorini

Offline

#7 2021-04-10 06:06:26

flydev
Member
From: France
Registered: 2020-11-27
Posts: 73
Website

Re: mORMot2 Wrapper generation broken

Just to say that it works on my side on Delphi 10.4.2 pro.

The only things I have to fix afterward, it's the included units (still generate "unit uses" from mORMot v1) :

uses
  SynCommons,
  mORMot;

and to comment the TTextWriter initialization :

// TTextWriter.RegisterCustomJSONSerializerFromText 
[...]

Offline

#8 2021-04-10 11:05:06

itSDS
Member
From: Germany
Registered: 2014-04-24
Posts: 516

Re: mORMot2 Wrapper generation broken

@flydev the Problem is here with nestet Records and Array of...

Here is a link to download my sample

for mORMot2 define USE_MORMOTV2 in the options

https://cloud.diestelmann-it-gmbh.de/s/iqQ9zCbRwKMmW8M


Rad Studio 12.1 Santorini

Offline

#9 2021-04-12 10:13:54

flydev
Member
From: France
Registered: 2020-11-27
Posts: 73
Website

Re: mORMot2 Wrapper generation broken

Okay, tried with your sample and I can confirm then.

Offline

#10 2021-06-14 13:47:07

itSDS
Member
From: Germany
Registered: 2014-04-24
Posts: 516

Re: mORMot2 Wrapper generation broken

hi Arnaud,

i had a look in the Source code and compared the Units "mORMotWrappers" and "mORMot.soa.codegen"

the TWrapperContext.ContextOneProperty seems to produce different structure.
But i have no idea how to fix it and where exactly the Problem is.
But in mORMot2 the nestedRecord Property is filled and in mORMot not for the same "TResultRec"

mORMot2:

{
	"typeWrapper": "wRecord",
	"typeSource": "TresultRec",
	"typeDelphi": "TresultRec",
	"typePascal": "TresultRec",
	"typeCS": "TresultRec",
	"typeJava": "TresultRec",
	"typeTS": "TresultRec",
	"typeSwagger": "TresultRec",
	"isRecord": true,
	"toVariant": "TresultRec2Variant",
	"fromVariant": "Variant2TresultRec",
	"propName": "resultRec",
	"fullPropName": "resultRec",
	"isSimple": null,
	"nestedRecord": {
		"nestedRecord": null,
		"fields": [
			{
				"typeWrapper": "wRawUtf8",
				"typeSource": "UTF8String",
				"typeDelphi": "RawUtf8",
				"typePascal": "String",
				"typeCS": "string",
				"typeJava": "String",
				"typeTS": "string",
				"typeSwagger": "{\"type\":\"string\"}",
				"propName": "erfolgJN",
				"fullPropName": "resultRec.erfolgJN",
				"nestedIdentation": "  ",
				"isSimple": true
			},
			{
				"typeWrapper": "wRawUtf8",
				"typeSource": "UTF8String",
				"typeDelphi": "RawUtf8",
				"typePascal": "String",
				"typeCS": "string",
				"typeJava": "String",
				"typeTS": "string",
				"typeSwagger": "{\"type\":\"string\"}",
				"propName": "fehlertext",
				"fullPropName": "resultRec.fehlertext",
				"nestedIdentation": "  ",
				"isSimple": true
			},
			{
				"typeWrapper": "wRawUtf8",
				"typeSource": "UTF8String",
				"typeDelphi": "RawUtf8",
				"typePascal": "String",
				"typeCS": "string",
				"typeJava": "String",
				"typeTS": "string",
				"typeSwagger": "{\"type\":\"string\"}",
				"propName": "hinweistext",
				"fullPropName": "resultRec.hinweistext",
				"nestedIdentation": "  ",
				"isSimple": true
			},
			{
				"typeWrapper": "wInteger",
				"typeSource": "Integer",
				"typeDelphi": "Integer",
				"typePascal": "Integer",
				"typeCS": "integer",
				"typeJava": "int",
				"typeTS": "number",
				"typeSwagger": "{\"type\":\"integer\"}",
				"propName": "resultcount",
				"fullPropName": "resultRec.resultcount",
				"nestedIdentation": "  ",
				"isSimple": true
			}
		]
	}
}

mORMot:

{
	"typeWrapper": "wRecord",
	"typeSource": "TresultRec",
	"typeDelphi": "TresultRec",
	"typePascal": "TresultRec",
	"typeCS": "TresultRec",
	"typeJava": "TresultRec",
	"typeTS": "TresultRec",
	"typeSwagger": "TresultRec",
	"isRecord": true,
	"toVariant": "TresultRec2Variant",
	"fromVariant": "Variant2TresultRec",
	"propName": "resultRec",
	"fullPropName": "resultRec",
	"isSimple": null
}

My be you have an idea how to fix it ?! It would be a great help. Ty


Rad Studio 12.1 Santorini

Offline

#11 2022-01-25 14:01:07

itSDS
Member
From: Germany
Registered: 2014-04-24
Posts: 516

Re: mORMot2 Wrapper generation broken

Hi Arnaud,

i like to move completely to mORMot2. But this feature is a show stopper atm.
I tested and debugged the Problem now for hours but can not solve it.
I just have some new hints and things i found out.

I use the same Sample as above. Slightly enhanced. if you like i can send you the code or show the Problem by Teamviewer.
i Compared the mORMot and mORMot2 by debugging TWrapperContent. And added some TSynLog Stuff to dig in the deep.

The Following Errors are in mORMot2:
1. Nested Records are expanded the reason is in the used new rtti props in ContextOneProperty function

for mORMot Version prop.PropertyType is ptCustom and for mORMot2 prop.Value.Parser is ptRecord
(generally it is a ptRecord but i do not know where mORMot generates the ptCustom where mORMot2 has a ptRecord.)
this adds additional nestedRecord in the structure. which is wrong.

2. Second BUG is a DynArray of (Record or simple Type e.g. String)
in mORMot the Code is correct
in M2 You internally map ptDynArray to Blob which results in wrong code. The Wrong Conversion occurs for example in ContextFromRTTI in

typ := TYPES_ORM[GetOrmFieldType(rtti.Info)];

Hopefully you have an idea to fix the Wrapper Generator with this info


Rad Studio 12.1 Santorini

Offline

#12 2022-01-27 14:50:13

itSDS
Member
From: Germany
Registered: 2014-04-24
Posts: 516

Re: mORMot2 Wrapper generation broken

Today I had another problem in the Wrapper Generator.
The generated ContractID is different between mORMot2 and mORMot.
However, after I inserted the one generated by mORMot, the data transfer still works.


Rad Studio 12.1 Santorini

Offline

#13 2022-08-27 07:06:20

itSDS
Member
From: Germany
Registered: 2014-04-24
Posts: 516

Re: mORMot2 Wrapper generation broken

Hi Arnaud, as you now completely switched to mORMot2 is there any chance that this bug will be fixed ?
This is the only reason for me to switch to mORMot1 sometimes.

tyvm


Rad Studio 12.1 Santorini

Offline

Board footer

Powered by FluxBB