You are not logged in.
@esmondb
Thanks for the Fuel UX tip. I didn't know about that one. Just like you I dislike CSS. ![]()
@Esteban
I didn't know about Google Polymer, thanks for the tip. Vaadin has always been an option. Their work looks good even if it is not free. ![]()
I finally settled on the following code
S := EmptyStr;
while Res.Step do
S := S + VariantSaveJSON(Res['resultat'], twNone);
Result := S;Browsers and REST clients show the JSON with escape characters but my Lazarus client application displays the JSON without escape characters which is OK for the moment. I don't know why this is so. If anyone has an idea why it is like that, please let me know.
JD
This does not work either even though I set TTextWriterKind to twNone.
S := EmptyStr;
while Res.Step do
S := S + VariantSaveJSON(Res['resultat'], twNone);
Result := S;I also tried S := S + VariantToString(Res['resultat']); and there are still escape characters in the JSON string. Has anyone dealt with this sort of problem before?
Thanks,
JD
OK. I didn't know that about OpenUI5. Thanks for letting me know this. I'll look elsewhere.
I must confess the idea of a mORMot server working with different types of frontends is a holy grail for me because the server part is always the hardest to code IMHO. Once I can get that part settled. I want to be able to play around with different types of clients.
I took a look at a Hibernate + Apache Tomcat based backend for an application again yesterday. It just seemed too heavy and unwieldy. A finely tuned mORMot server (Linux/Windows) just seems to me more logical as a replacement. A seperate forum on such an topic will be the best because we all know that at enterprise level, Java EE (with Tomcat or Glassfish) is deeply entrenched. And that is where I want to go.
JD
Hi there all,
I am using an interface based service to get data from a PostgreSQL database. Some of the data comes from functions that already return JSON data using PostgreSQL JSON functions like row_to_json(_) and json_agg(). The problem is that the interface service returns JSON with escape characters. For example instead of returning
[{"resultat": {"resource": "/genre", "genre": [{"numero": 1,"description": "Femme"},{"numero": 2,"description": "Homme"}]}}]generated by the PostgreSQL database, FetchAllToJSON returns
[{\"resultat\":\"{\\\"resource\\\":\\\"/genre\\\",\\\"genre\\\":[{\\\"numero\\\":1,\\\"description\\\":\\\"Femme\\\"}, \\n {\\\"numero\\\":2,\\\"description\\\":\\\"Homme\\\"}]}\"}]The relevant lines in the service code are
function TRESTMethods.Gender(aURI: string; aID: integer): RawJSON;
begin
...
Res := aServer.fDbProps.Execute(Format('select * from genre(%s)', [QuotedStr(aURI)]), []);
Result := Res.FetchAllAsJSON(True);
...
end;Is there an alternative to using FetchAllAsJSON that can just accept and return the PostgreSQL generated JSON as-is?
Thanks,
JD
Fpcupdeluxe presents you two mORMots:
the original one: mORMot
a special one: mORMotFPCThe latter was made to be able to use the mORMot during a period of heavy changes of FPC and the mORMot itself.
It has not been updates for a long time now: the original mORMot works flawless now with FPC on many systems.So, just use the original mORMot.
Noted! Thanks a lot DonAlfredo. I really admire the work you've done with fpcup since we (the Lazarus community) lost BigChimp who started it all. I'm also interested in how you use mORMot with OpenUI5 but that will be another discussion.
JD
Hi there ab. I was using fpcupdeluxe to download mORMot so I tried the mORMotNightlyBuild for a change. While fpcupdeluxe fetches mORMot 1.18.3680 FTS3, the nightly build I got is mORMot 1.18.3857 FTS3!? So fpcupdeluxe is no longer in sync with the mORMot nightly builds.
Anyway I used Lazarus (NewPascal & also Lazarus 1.8RC4/fpc 3.0.2) to compile/run TestSQL3 and though all assertions were passed, some tests related to compression failed.
1.5 Compression:
! Compression - GZIP format
! Exception ESynZipException raised with message:
! Error -5 during UnCompression processIn any case it looks like Lazarus can now create SQLite3 databases again.
By the way, I would like to inform you that I've also been using mORMot with ZEOS & PostgreSQL 9.5 and 9.6 with success. In the manual, you asked users to let you know of successful test cases with newer PostgreSQL releases.
So thanks a lot.
JD
Lazarus (NewPascal & Lazarus 1.8RC4/fpc 3.0.2) can no longer create SQLite3 databases using TSQLRestServerDB.Create. I am using mORMot 1.18.3680 FTS3
While it works OK in my Delphi 2010, I had to use the work around below and create the REST server in memory when I switch to Lazarus. Lazarus used to be able to create SQLite3 databases so maybe some recent changes to mORMot are responsible for this failure.
{$IFNDEF fpc}
{$IFDEF SQLITE_DB_ON_DISK}
DBServer := TSQLRestServerDB.Create(Model, DBNAME,{$IFDEF AUTHENTICATION}True{$ELSE}False{$ENDIF});
{$ELSE}
DBServer := TSQLRestServerDB.Create(Model, ':memory:',{$IFDEF AUTHENTICATION}True{$ELSE}False{$ENDIF});
{$ENDIF}
DBServer.CreateMissingTables;
{$ELSE}
DBServer := TSQLRestServerFullMemory.Create(TSQLModel.Create([], ROOT_NAME), 'atheme.json', False, {$IFDEF AUTHENTICATION}True{$ELSE}False{$ENDIF});
{$ENDIF}Apart from that issue everything is working fine in Lazarus; even my service based interfaces. I am amazed at how easy it is to create interfaces and I see that I no longer need to manually create and map URI REST commands. So my code will be much smaller as a result. I've decided to go full throttle with mORMot because of this.
Thanks a lot to Arnaud & the rest of the team. You are doing a wonderful job & I can't praise you enough.
JD
Thanks a lot ab. It worked!!!
However, I assumed that the data created when the model was created will be stored in memory. I had created a table Genre with the following initial data in the model
// Add default record for the genre table
if DBClient.TableRowCount(TSQLGenre) = 0 then
begin
Genre := TSQLGenre.Create;
//
try
Genre.Description := UTF8ToString('Feminin');
Genre.CreationBy := TSQLUtilisateur(1);
DBClient.Add(TSQLRecord(Genre), True);
Genre.Description := UTF8ToString('Masculin');
Genre.CreationBy := TSQLUtilisateur(1);
DBClient.Add(TSQLRecord(Genre), True);
finally
Genre.Free;
end;
end; // if DBClient.TableRowCount(TSQLGenre) = 0When I save the DB on disk and then access the table from the browser, I get the JSON result [{"ID":1},{"ID":2}], which is correct BUT when the DB is in memory, browser access returns the JSON result {"fieldCount":1,"values":["ID"],"rowCount":0} which is not correct! What am I doing wrong while accessing my in-memory DB?
Thanks a lot,
JD
Hello,
I'm trying to make an in-memory SQLite3 database accessible via HTTP but it doesn't seem to be working.
I use the code below to create the in-memory database when I undefine SQLITE_DB_ON_DISK
{$IFDEF SQLITE_DB_ON_DISK}
DBServer := TSQLRestServerDB.Create(Model, DBNAME, {$IFDEF AUTHENTICATION}True{$ELSE}False{$ENDIF});
{$ELSE}
DBServer := TSQLRestServerDB.Create(Model, ':memory:', {$IFDEF AUTHENTICATION}True{$ELSE}False{$ENDIF});
{$ENDIF}
DBServer.CreateMissingTables;
//
// Create the HTTP Server
// Register URI first otherwise error is thrown
{$IFDEF SQLITE_DB_ON_DISK}
Server := TSQLHttpServer.Create(DEFAULT_HTTP_PORT, [DBServer], '+', HTTP_DEFAULT_MODE);
{$ELSE}
Server := TSQLHttpServer.Create(DEFAULT_HTTP_PORT, [], '+', HTTP_DEFAULT_MODE);
{$ENDIF}
Server.AccessControlAllowOrigin := '*'; // allow cross-site AJAX queriesif I use [':memory:'] with the HTTP server like this,
Server := TSQLHttpServer.Create(DEFAULT_HTTP_PORT, [':memory:'], '+', HTTP_DEFAULT_MODE)the compiler says there is no overloaded version of 'Create' that can be called with these arguments.
What do I need to correct?
Thanks a lot.
On which platform?
Windows 7 64 bit but using Lazarus/NewPascal 32 bit versions. Delphi 2010
You need a true sqlite engine in front of the external database.
Use TSQLRestServerDB, as documented.
Hi there ab,
I have established that the problem is due to the fact that the most recent version of mORMot (Version 1.18.3680 FTS3) has problems with Lazarus. I tried to compile TestSQL3.lpi using
a) Lazarus 1.8RC4/FPC 3.0.4
b) Lazarus stable (1.6.4/FPC 3.0.2)
c) NewPascal
While all three compiled without problems, the TestSQL3 executable produced by (a) and (b) does not run/work even in administrator mode. As for (c), the TestSQL3 executable worked and passed all the tests as expected BUT after it finishes and you press ENTER to close the console windows, an unending repeating sequence of error messages appears
Internal error: Unknown dwarf form: $17
Internal error: Unknown dwarf form: $19
TASK, line 5713 of ..\SynCrtSock.pas
EXECUTE, line 5671 of ..\SynCrtSock.pasIt is curious because all TestSQL3 executables produced by these Lazarus versions used to work before.
For the moment, I'll stick to using Delphi when I use mORMot (which means no Linux) but do you think it is worth investigating.
Thanks,
JD
Hi there,
I'm having some trouble creating an instance of TSQLRestServerFullMemory to use with some interface based services in front of a Firebird database. My code is as follows
procedure TfrmSakilaServer.StartServer;
begin
//
Model := TSQLModel.Create([], ROOT_NAME);
DB := TSQLRestServerFullMemory.Create(Model, false);
// register our ISakilaRESTInterface service on the server side
DB.ServiceRegister(TSakilaRESTMethods, [TypeInfo(ISakilaRESTInterface)], SERVICE_INSTANCE_IMPLEMENTATION).
SetOptions([], [optExecInMainThread, optFreeInMainThread]);
HttpServer := TSQLHttpServer.Create(DEFAULT_HTTP_PORT, [DB], '+', HTTP_DEFAULT_MODE, 32, secNone);
HttpServer.AccessControlAllowOrigin := '*'; // allow cross-site AJAX queries
end;The problem is with the line
DB := TSQLRestServerFullMemory.Create(Model, false);What is wrong with my code?
Thanks for your assistance,
JD
Merci infiniment AB,
It worked! I've even created a template from it that I can use for different projects. mORMot is like an onion; it has many layers and peeling away each layer reveals something new.
JD
Hi there AB,
I've been struggling with this RTTI problem for a while. I tried a NewPascal version that I downloaded a week ago and for some reason it gave me an error in line 18247 of SynCommons.pas saying Unknown Codepage; "1200".
I then reverted to Delphi 2010 to try to generate the missing unit.
The program dpr file is as shown below (it is a short file):
program BasicCalculatorClientDelphi;
{$define COMPUTEFPCINTERFACES}
uses
{$I SynDprUses.inc} // use FastMM4 on older Delphi, or set FPC threads
mORMotWrappers,
//
SysUtils, // for ExtractFilePath
//
Forms,
uClientForm in 'uClientForm.pas' {frmBasicCalculator},
ucalculatorinterface in '..\ucalculatorinterface.pas',
ucalculatorinterfacemethods in '..\ucalculatorinterfacemethods.pas';
{$R *.res}
begin
Application.Initialize;
Application.MainFormOnTaskbar := True;
Application.CreateForm(TfrmBasicCalculator, frmBasicCalculator);
Application.Run;
{$ifdef COMPUTEFPCINTERFACES}
ChDir(ExtractFilePath(ParamStr(0)));
ComputeFPCInterfacesUnit(
['..\CrossPlatform\templates','..\..\CrossPlatform\templates'],
'..\CalculatorFPCInterface.pas');
{$endif}
end.The problem is CalculatorFPCInterface.pas is not being generated by Delphi 2010. What am I missing? Thanks for your assistance.
JD
Thanks a million ab. And thanks for the wonderful work you all are doing with mORMot. I haven't totally adopted NewPascal because my old work uses client side components that don't work in NewPascal.
If I understand what is written in the manual, it means I must compile at least the server code using Delphi to generate the XXXFPCInterface.pas file and then I can transfer it to my client & server projects in Lazarus.
Hi there everyone,
I'm trying to adapt the third party example by George to get a feeling for creating interface SOA in Lazarus. The example compiles and works in Lazarus and that is why I'm interested in studying it. Inside George's example, there is a pascal file mORMotRESTFPCInterfaces.pas with the following header
/// SOA interface methods definition to circumvent FPC missing RTTI
// - generated at 2016-07-27 09:30:40
unit mORMotRESTFPCInterfaces;
{
WARNING:
This unit has been generated by a mORMot 1.18.2797 server.
Any manual modification of this file may be lost after regeneration.
Synopse mORMot framework. Copyright (C) 2017 Arnaud Bouchez
Synopse Informatique - https://synopse.info
This unit is released under a MPL/GPL/LGPL tri-license,
and therefore may be freely included in any application.
This unit is intended to work on older FPC compilers, which lack of RTTI
for interfaces - see http://bugs.freepascal.org/view.php?id=26774
USAGE:
Add this mORMotRESTFPCInterfaces unit to your uses clause, so that the following
interfaces would be defined as expected by mORMot under FPC:
- IRestMethods
}It says this file was generated automatically BUT it does not say how it was done. Can anyone please tell me what I need to do to generate a file such as this for my test project.
Thanks a lot for your help.
JD
C'est vrai. Je peux le utiliser avec Lazarus. Et je confime aussi que les accents français marche. Mais pardon moi, je ne veut que les parties SAD et SDD. Dois-je faire le saisi directment dans le << Wizard >> ou ça peut être une pièce jointe? En plus, comment supprimer les autres parties non souhaités dans le document finale?
Finalement, est-il possible de voir le fichier .pro que le << Wizard >> avez crée pour le documentation officiel du mORMot.
Mille mercis,
JD
Thanks for your reply ab. How do I change it in the code? I want to generate French documentation.
JD
Hi there everyone,
Thanks for the wonderful SynProject tool. I was wondering if it was possible to use it for Lazarus projects and if it can generate documentation in languages other than English.
Thanks,
JD
Can anyone help me, please? I just need to see a simple example where a raw INSERT SQL with say 50 inserts (a relatively small number) is converted entirely to using BatchAdd.
Thanks for the link but I still don't understand. How do I populate the object before looping through the contents?
I was thinking of something along the lines of a
LoadFromStream()
LoadFromFile('countries.sql')
LoadFromCSV('countries.csv')
and so on. Thanks a lot for your help.
As part of an effort to slowly migrate an application to the mORMot ORM, I have to perform bulk inserts to many tables after creating the tables.
All my setup code is in a HUGE SQL file that I use for preparing the tables in the database. The INSERT SQL for the country table above puts all 193 countries of the world into the table.
I have read about the Batch procedure but I don't know how to move from pure SQL to ORM Batch without having to type every line to be added as follows
procedure TfrmServeur.InitializeTables;
var
Country: TSQLCountry; // TSQLCountry derives from TSQLBaseRecord which derives from TSQLRecord
begin
DBClient := TSQLRestClientDB.Create(TSQLModel(TSQLCountry), nil, DBNAME, TSQLRestServerDB);
//
if DBClient.TableRowCount(TSQLCountry) = 0 then
begin
Country := TSQLCountry.Create;
try
// Add the 193 countries
Country.Name := 'Afghanistan';
DBClient.Add(TSQLRecord(Country), True);
Country.Name := 'Albania';
DBClient.Add(TSQLRecord(Country), True);
......
Country.Name := 'Zimbabwe';
DBClient.Add(TSQLRecord(Country), True);
finally
User.Free;
end;
end;
end;Is there a better way to do this especially since some of the tables contain over 30,000 entries in the INSERT SQL?
Thanks,
JD
Yep.
The most simple way to get Lazarus working with the mORMot, is just to open the dpr file as a normal Lazarus project.
Lazarus will then ask you if it has to create a Lazarus project.
Select Simple Program for command line samples.
Select Application for samples with a form.After that, set the correct paths for
"Other unit files" ... has to point to both the mORMot base directory and the SQLite3 directory.
"Include files" ... has to point to the mORMot base directory.That's it !
Thank you very much!
It happened again! I just tried to convert a mORMot Delphi project to Lazarus. And I simply could not understand why a perfectly working mORMot installation should suddenly fail. By a stroke of luck, I found the following thread http://synopse.info/forum/viewtopic.php?id=2175
The culprit is the Delphi to Lazarus converter which according to AOG modifies mORMot. Point taken. But maybe we need to add this information to the documentation or make it a sticky on this forum so that Lazarus users won't continue to experence this problem and ask this same question repeatedly.
JD
Thanks AB, I am going to implement your solution.
How did you eventually implement your paging solution while respecting ORM rules? Is the pagination on the client side or on the server side?
Thanks,
JD
Hi turrican,
Thanks for your reply. I'll take note of your suggestion.
JD
Thanks a lot! I'm off to a flying start.
JD
Hi there everyone,
After much effort (thanks to ab and DonAlfredo/AOG (- fpcup is really great!)), I succeeded in getting mORMot to work for me on my Lazarus/FPC installations (Lazarus 1.6/FPC 3.0 and Lazarus 1.7/FPC 3.1.1).
I am simply overwhelmed at how the framework is put together and how much time it could save me with development once I get the data model right. I spend long hours writing and optimizing SQL code so you can imagine how I feel.
I have been reading the documentation as well as trying the examples on the site https://tamingthemormot.wordpress.com/2 … tionships/. However I ran into a problem and I tried a workaround that worked but I'm not sure if I did the right thing.
My modified code with the workaround is shown below
//
procedure TestNoteCase(Rest: TSQLRest);
var
aCase: NoteORM.TNoteCase;
aNote: NoteORM.TNote;
begin
//
aCase := NoteORM.TNoteCase.Create;
//
try
//
aCase.Description := 'Case 1';
Rest.Add(aCase, True);
//
aNote := NoteORM.TNote.Create;
//
try
aNote.Title := 'Note 1';
aNote.Body := 'Note 1 body. Lots of other stuff too.';
// Notes.lpr(63,31) Error: Incompatible types: got "Pointer" expected "TNoteCase"
//aNote.NoteCase := aCase.AsTSQLRecord;
aNote.NoteCase := TNoteCase(aCase.AsTSQLRecord); <---- IS THIS OK?
Rest.Add(aNote, True);
//
aNote.Title := 'Note 2';
aNote.Body := 'Note 2 body. Lots of other stuff too.';
// Save a nil to the record
aNote.NoteCase := TNoteCase(nil); <---- IS THIS OK?
Rest.Add(aNote, True);
finally
aNote.Free;
end;
finally
aCase.Free;
end;
end;The lines with <---- IS THIS OK? are the ones I'm not sure about. The original line
aNote.NoteCase := aCase.AsTSQLRecord;gave me an error
Error: Incompatible types: got "Pointer" expected "TNoteCase"
so I changed it to
aNote.NoteCase := TNoteCase(aCase.AsTSQLRecord);and I used
aNote.NoteCase := TNoteCase(nil);to save a nil or zero reference to the table because I found out that the second record retained the value of aNote.NoteCase from the first record.
It worked but am I doing the right thing?
Thanks,
JD
Hi there everyone,
I'm using Lazarus 2.6 and FPC 3.0 and and I've decided to take another look at mORMot. However I need some clarification on a few things
a) First of all, the default Delphi build for mORMot does not integrate well with Lazarus at all and all the example projects are in Delphi and it is almost impossible to get it to compile in Lazarus
b) Thanks to DonAlfredo/LongDirtyAnimAlf, I was able to get a version of mORMot tweaked for Lazarus. I was able to compile the test and a few examples which had already been converted to Lazarus like 04 HTTP Client-Server. However, as soon as I tried to convert the other Delphi based projects to Lazarus, the problems started. I kept running into a brick wall in SynCommons.pas at SystemInfo: TSystemInfo; with the error below
{code}
SynCommons.pas(11751,15) Error: Identifier not found "TSystemInfo"
{/code}
The funny thing is that I have an older copy of SynCommons.pas that I used in one of my old projects and this error does not show up. How do I solve this problem
c) I do not know where I can get a mORMot version of Lazarus in sync with the mORMot nightly build.
Overall I like mORMot and would very much like to give it a try, but the difficulties with Lazarus are holding me back. If you want to support Lazarus you really have to make available a parallel version that supports Lazarus out of the box because many of us have left Delphi and do not want to go back.
Thanks for your good work,
JD
Thanks a lot for your reply. I did as you suggested & I installed the getlazarus package. But after trying to compile TestSQL3 I got the following compiler errors even after I put sqlite3.dll in the project directory
Compile Project, Mode: linux, Target: fpc\i386-win32\TestSQL3.exe: Exit code 1, Errors: 3
TestSQL3.dpr(190,1) Error: Can't open object file: fpc-win32\sqlite3.o
TestSQL3.dpr(190,1) Error: Can't open object file: libkernel32.a
TestSQL3.dpr(190,1) Error: Can't open object file: libgcc.a
Regards,
JD
Hi there everyone,
I use Lararus 2.6/fpc 3.0 32bit on Windows 7 64bit. I've been trying to compile test project & examples (TestSQL3 & 01 - In Memory ORM) of the mORMot framework & I keep getting a strange error on line 23363 in mormot.pas
SetID(fIDColumn[Row],result) elseThe error is as stated below:
mORMot.pas(23363,7) Error: Internal error 2006111510
I noticed that this has already been reported before but I don't know if it has been resolved.
Thanks a lot for your time.
JD