You are not logged in.
Hi,
With the following code, it doesn't work in a TSQLRestStorageInMemory REST storage, but in TSQLRestServerDB works like a charm:
TSQLiniDB = class(TSQLRecordVirtualTableAutoID)
private
fSeccio : RawUTF8;
fCamp : RawUTF8;
fValor : RawUTF8;
published
property Seccio : RawUTF8 read fSeccio write fSeccio;
property Camp : RawUTF8 read fCamp write fCamp;
property Valor : RawUTF8 read fValor write fValor;
end;
...
...
var
ModelSettings : TSQLModel;
SettingsDB : TSQLRestServer;
...
...
procedure ORMInit;
begin
ModelSettings := TSQLModel.Create([TSQLiniDB]);
ModelSettings.VirtualTableRegister(TSQLiniDB,TSQLVirtualTableJSON);
SettingsDB := TSQLRestServerFullMemory.create(ModelSettings,'settings.json',false,false);
end;
...
...
var ORMiniDB : TSQLiniDB
Seccio,Camp,Valor:string;
begin
Seccio := 'General';
Camp := 'Path';
Valor := 'c:\';
ORMiniDB := TSQLiniDB.CreateAndFillPrepare(SettingsDB,'Seccio=? AND Camp=?',[StringToutf8(Seccio),StringToUTF8(Camp)]);;
try
ORMiniDB.FillOne;
ORMiniDB.Seccio := StringToUTF8(Seccio);
ORMiniDB.Camp := StringToUTF8(Camp);
ORMiniDB.Valor := StringToUTF8(Valor);
SettingsDB.AddOrUpdate(ORMiniDB);
finally
ORMiniDB.Free
end;
end;
Even the pair fields 'Seccio' 'Camp' exists, AddOrUpdate adds a new register instead of update. In a sqlite database storage it works well.
Is there something wrong?
Many thanks
Last edited by xalo (2016-11-25 17:38:46)
Offline
Except from the doc:
If your purpose is not to have a full SQLite3 engine available, you may create your server from a
TSQLRestServerFullMemory class instead of TSQLRestServerDB : this will implement a fast
in-memory engine (using TSQLRestStorageInMemory instances), with basic CRUD features (for ORM),
and persistence on disk as JSON or optimized binary files - this kind of server is enough to handle
authentication, and host services in a stand-alone way.
You might instead want to use TSQLRestServerDB with ':memory:' (without the quotes) as the filename? reference is here: https://www.sqlite.org/inmemorydb.html
Last edited by edwinsn (2016-11-26 07:48:25)
Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.
Offline
ok!...but is so so so fast!!! :-(
Maybe it would be possible apply only one condition for prepare, and the second one through a fillone iterating.
Really really good framework!
Awesome!
Many thanks
Offline
Or you could also directly access the TList containing the TSQLRecord, so you can do whatever request you expect, directly on the records.
Ensure you protect your direct use with StorageLock/StorageUnlock method calls.
Offline