Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
new regression tests
  • Loading branch information
Arnaud Bouchez committed Feb 13, 2023
1 parent ef40fae commit 518702f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/mormot.commit.inc
@@ -1 +1 @@
'2.0.4874'
'2.0.4875'
30 changes: 28 additions & 2 deletions test/test.orm.core.pas
Expand Up @@ -126,6 +126,14 @@ TTestOrmCore = class(TSynTestCase)

implementation

type
TOrmJson = class(TOrm)
protected
fJson: RawJson;
published
property Json: RawJson
read fJson write fJson;
end;

{ TTestOrmCore }

Expand All @@ -135,11 +143,12 @@ procedure TTestOrmCore._TOrmModel;
U: TRestServerUri;
met: TUriMethod;
begin
M := TOrmModel.Create([TOrmTest]);
M := TOrmModel.Create([TOrmTest, TOrmJson]);
try
Check(M['Test'] <> nil);
Check(M['Test2'] = nil);
Check(M['TEST'] = TOrmTest);
Check(M['Json'] = TOrmJSON);
finally
M.Free;
end;
Expand Down Expand Up @@ -515,6 +524,8 @@ procedure TTestOrmCore._TOrm;
wa: WinAnsiString;
M: TOrmModel;
T, T2: TOrmTest;
J, J2: TOrmJson;
pi: TOrmPropInfo;
s3: RawUtf8;
bin: RawByteString;
valid: boolean;
Expand Down Expand Up @@ -549,13 +560,27 @@ procedure TTestOrmCore._TOrm;
Check(RawUtf8ArrayToCsv(GetTableNamesFromSqlSelect(
'select a,b from titi, tutu , tata where a=2')) = 'titi,tutu,tata');
T := TOrmTest.Create;
M := TOrmModel.Create([TOrmTest]);
J := TOrmJson.Create;
M := TOrmModel.Create([TOrmTest, TOrmJson]);
for i := 0 to GetRttiProp(TOrmTest, P) - 1 do
begin
Check(TOrmTest.OrmProps.Fields.IndexByName(LowerCase(P^.NameUtf8)) = i);
Check(T.OrmProps.Fields.ByRawUtf8Name(P^.NameUtf8) <> nil);
P := P^.Next;
end;
for i := 0 to GetRttiProp(TOrmJson, P) - 1 do
begin
Check(TOrmJson.OrmProps.Fields.IndexByName(LowerCase(P^.NameUtf8)) = i);
pi := J.OrmProps.Fields.ByRawUtf8Name(P^.NameUtf8);
check(pi <> nil);
if pi.name = 'Json' then
begin
check(pi.SqlDBFieldType = ftUtf8);
check(pi.OrmFieldType = oftUtf8Text);
check(pi.OrmFieldTypeStored = oftUtf8Text);
end;
P := P^.Next;
end;
Check(TOrmTest.OrmProps.Fields.IndexByName('') < 0);
Check(TOrmTest.OrmProps.Fields.IndexByName('none') < 0);
Check(TOrmTest.OrmProps.Fields.IndexByName('nex') < 0);
Expand Down Expand Up @@ -702,6 +727,7 @@ procedure TTestOrmCore._TOrm;
M.Free;
T2.Free;
T.Free;
J.Free;
end;
end;

Expand Down

0 comments on commit 518702f

Please sign in to comment.