#1 2015-08-15 21:29:46

mariomoretti
Member
From: italy
Registered: 2012-01-29
Posts: 88

sqlrecord properties are assigned as int32

I've two classes

ClassA = class(tSqlRecord)
protected
   fdesA : rawutf8;
published 
   property desA : rawutf8 read fDes write fDes; 
end;

ClassB = class(tSqlRecord)
protected
   fdesB : rawutf8;
   fA : ClassA; 
published 
   property desB : rawutf8 read fDesB write fDesB; 
   property A : ClassA read fA write fA;
end;
 

In class a there is an instance with ID = maxint + 1 (2147483648).


procedure test;
var a : classa;
      b : classb;
     aID : tID;
begin
        a := classa.create;
        a.desa := 'A';
        a.idvalue :=  2147483648;
        server.add(A, true, true);
        b := classb.create;
        b.desb := 'B';
        b.A := A.Astsqlrecord;
        aID := server.add(b, true);
        b.free;
        b := classb.create(server, aID);
        aID := b.A.ID;    // here an access violation error is returned.
        b.free;
        a.free;
end;

Debugging i've seen that in mormot.pas the assigment of value to property b.A is done using TSQLPropInfoRTTIInt32 class instead of TSQLPropInfoRTTIInt64.

Offline

#2 2015-08-16 07:41:27

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

Re: sqlrecord properties are assigned as int32

By definition: ClassA = TObject = pointer = 32 bits = stored as Int32.

If you want 64 bit IDs, use TID or you own TID sub-type.

All is explained at http://synopse.info/files/html/Synopse% … l#TITLE_54
A little search in the doc would always help, right?

Offline

#3 2015-08-16 08:45:56

mariomoretti
Member
From: italy
Registered: 2012-01-29
Posts: 88

Re: sqlrecord properties are assigned as int32

I may agree about little search but... i haven't done any search , thinking that record properties should permits to store any record.
Sorry.

Offline

#4 2015-08-16 11:15:22

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

Re: sqlrecord properties are assigned as int32

No problem.

wink

Offline

#5 2015-08-16 12:51:45

mariomoretti
Member
From: italy
Registered: 2012-01-29
Posts: 88

Re: sqlrecord properties are assigned as int32

ok ab,

as we know , the documentation of this big framework is BIG.
What about raise an axception on b.A=A.AstSqlRecord if A.ID is greater than maxint? It could avoid any misunderstanding (now , in the db field,  is stored 2147483648!).

Offline

#6 2015-08-16 14:52:45

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

Re: sqlrecord properties are assigned as int32

Offline

Board footer

Powered by FluxBB