You are not logged in.
Hi,
TObjectList<T>(TSQLRestServerDB.RetrieveList()) seems broken (or I don't know to invoke these) .
This code fails :
uses
System.SysUtils,
mormot,
mORMotSQLite3,
mORMotDB,
System.Generics.Collections,
synsqlite3static;
type
TUser = class(TSQLRecord)
private
fname: UTF8String;
fgroupid: TID;
published
property IDGroup: TID read fgroupid write fgroupid;
property Name: UTF8String read fname write fname;
end;
var
fSQLContext: TSQLRestServerDB;
userlist: TObjectList<TUser>;
user: TUser;
begin
try
{ TODO -oUser -cConsole Main : Insert code here }
fSQLContext:=TSQLRestServerDB.Create(TSQLModel.Create([TUser], 'root'),'prueba.db3');
fSQLContext.CreateMissingTables;
for user in TObjectList<TUser>(fSQLContext.RetrieveList(TUser, 'IDGroup=?', [4])) do
begin
writeln(user.Name);
end;
readln;
except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end;
end.
This don't :
uses
System.SysUtils,
mormot,
mORMotSQLite3,
mORMotDB,
System.Contnrs,
synsqlite3static;
type
TUser = class(TSQLRecord)
private
fname: UTF8String;
fgroupid: TID;
published
property IDGroup: TID read fgroupid write fgroupid;
property Name: UTF8String read fname write fname;
end;
var
fSQLContext: TSQLRestServerDB;
user: Pointer;
begin
try
{ TODO -oUser -cConsole Main : Insert code here }
fSQLContext:=TSQLRestServerDB.Create(TSQLModel.Create([TUser], 'root'),'prueba.db3');
fSQLContext.CreateMissingTables;
for user in TObjectList(fSQLContext.RetrieveList(TUser, 'IDGroup=?', [4])) do
begin
writeln(TUser(user).Name);
end;
readln;
except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end;
end.
Offline
Source : Delphi XE8 Using Generics
Case : RetrieveList() returns nil list. Access violation while iterate list.
Inside code : Investigating a little I see the next method :
function TSQLRest.RetrieveList<T>(const FormatSQLWhere: RawUTF8; const BoundsSQLWhere: array of const; const aCustomFieldsCSV: RawUTF8): TObjectList<T>;
innacessible due a not defined constant in the compiler conditional :
{$ifdef ISDELPHI2010}
So, the compiler calls another method instead
function RetrieveList(Table: TSQLRecordClass; const FieldNames, SQLWhere: string; const BoundsSQLWhere: array of const): TObjectList;
I don't know why this constant isn't defined in XE8...
Last edited by turrican (2015-09-02 15:47:36)
Offline