You are not logged in.
Hi,
I am trying to find out what I need to do to implement a class with a property of TOBjectList.
My classes looks like
TSQLPlayer = class(TSQLRecord)
...
end;
TListPlayer = TObjectList<TSQLPlayer>;
TSQLGame = class(TSQLRecord)
private
fPlayers:TListPlayer;
...
published
property Players:TListPlayer read fPlayers write fPlayers;
end;This codes compiles with no errors; But in runtime I get the following exception:
EORMException with message 'Unhanled type for property Players'.
This happens in TSQLModel.Create([TSQLGame, TSQLPlayer], 'root');
Did I failed to do some initialization here?
Merci,
Wai
A wizard would definitely aide in adopting lots of mORMots
.
Maybe FPC support can be implemented in two phases? First the client side, then the server?
Where is the like button
...
The 5 MB file is no problem to download. It is quite fast.
Great videos, if only they played a littel bit slower ...
Yes, changing from RawJSON to RawUtf8 solved the problem.
Merci, Arnaud.
Also cool, that I don't have to log in to get the latest source. The Nightbuilds are really handy.
Hi everyone,
I have a client made with Smart Mobile Studio and a Mormot server communicating through an interface. This setup is build on
the units written by LoPiTaL. I am sending JSON string from the client to the server. When accessing this string (using JSONToObject)
I get an access violation. Tracing into JSONToObject I
see that the string is "", although in the debugger the string passed from the client is shown.
In the client, the parameter is declared as string and in mormot it is RawJSON.
Does anyone have an idea what is happening and what is the correct way to pass string args?
Thanks in advance,
Wai
Hi guys,
What are your thoughts about a FAQ section for mORMot?
Cheers,
Wai
So this snippet of code should change the password of the default user?
fServer := TSQLRestServerFullMemory.Create(fModel,'.\test.json',false,true);
fServer.CreateMissingTables(0);
aMormotUser := TSQLAuthUser.Create(fServer, 'Name=?', ['User']);
aMormotUser.PasswordPlain := 'NewPasswd';
assert( fServer.Update(aMormotUser), 'Default User password not changed!');
Unfortunately, the assert fails. What else needs to be done, so the password is changed? Or is this not the way to go?
RTFM!
Indeed RTFM (or RTFF
), if i knew what to look for. I search in the SAD for 'http.sys', 'authorize', but not AddUrlAuthorize. Unfortunately,
my pdf reader cannot do partial searches.
This brings me to these questions:
- when using mORMot authentication scheme, do I have to use sqlite3 for persistence?
- is it also possible to use an external database for user/pw persistence?
It might be that these questions has already been answered, so feel free to RTFM me
.
hi MPV, thanks for clarifying.
I have noticed that the EOSError only occurs when running 'this' Project04client in Delphi and not when running the executable. When I run a Project04client from
a different sample then also no problem.
I then decided to remove Project04Client from the project group, delete all files generated by Delphi (.dproj, .res) and added the project back to the project group.
And then no problem ...
The URI is registerer in :
procedure TForm1.FormCreate(Sender: TObject);
begin
Model := CreateSampleModel;
DB := TSQLRestServerDB.Create(Model,ChangeFileExt(paramstr(0),'.db3'),true);
DB.CreateMissingTables(0);
Server := TSQLHttpServer.Create('8080',[DB],'+',useHttpApiRegisteringURI);
Server.AccessControlAllowOrigin := '*'; // allow cross-site AJAX queries
end;
Right?
When running only the executables, everything is fine. When running the client in IDE, the EOSError (Systemerror, Code 12002) appears.
Ah, sorry. I was not clear on which side it is. This is on the server side.
ahaa, so that is why the field Grouprights in table authuser has such a big number instead of the value 3. (Learned something new again, usage of MainFieldID)
allright, so now i have made the suggested changes and now I see the value 3 in the grouprights field.
The new code looks like:
procedure TForm1.Button2Click(Sender: TObject);
var
aNewUser:TSQLAuthUser;
begin
aNewUser := TSQLAuthUser.Create;
try
aNewUser.PasswordPlain := edit2.Text;
aNewUser.LogonName := edit1.Text;
aNewUser.DisplayName := edit1.Text;
aNewUser.Grouprights := pointer(DB.MainFieldID(TSQLAuthGroup,'User'));
if DB.Add(aNewUser, true)<>0 then begin
showmessage('User '+ aNewUser.LogonName + ' added.');
end;
finally
aNewUser.Free;
end;
end;Now the issue is that when I add a new user to the database and in the client I use SetUser('User', 'synopse') everything works according to plan. But, when
I use SetUser('wai', 'test') I cannot add any data with the client. When running the client in Delphi I see that an EOSError (message 'System error. Code 12002') occurs.
Tracing the call I see that this happens at
lineno 21572. aNonce := CallBackGetResult('auth',['UserName',U.LogonName]);in unit mORMot.
Hi all,
I am looking into the authentication mechanism of mORMot. Just checking if I am on the right track.
For this purpose I have modified Sample 4.
I have put 2 Tedit and a Tbutton component to the form of the server. When the button is clicked a new user is added
to the database. Below is the code snippet in the onclick eventhandler of the button.
procedure TForm1.Button2Click(Sender: TObject);
var
aNewUser:TSQLAuthUser;
begin
aNewUser := TSQLAuthUser.Create;
aNewUser.PasswordPlain := edit2.Text;
aNewUser.LogonName := edit1.Text;
aNewUser.GroupRights := TSQLAuthGroup.Create(DB, 'Ident=?', ['User']);
if DB.Add(aNewUser, true)<>0 then
showmessage('User '+ aNewUser.LogonName + ' added.');
end;When checking project04server.db3 with SqliteMan, I see that a corresponding record has been created in table AuthUser.
Unfortunately, when starting the client (in Delphi XE) an EOSException is raised with message 'System Error. Code 12002' at
TSQLHttpClient(Form1.Database).SetUser('wai','test');When I try to delete the new record in table AuthUser with SqliteMan I get a notification that I cannot commit because a pending
transaction is in progress.
What am I missing? Remarks and tips much appreciated.
Thanks,
Wai
Nice video.
An example on how to implement authentication in mORMot is much appreciated.
back again fiddling with SynDBZeos.
so when using function URI of TSQLDBZEOSConnectionProperties the function call would look like:
fDatabase := TSQLDBZEOSConnectionProperties.Create(TSQLDBZEOSConnectionProperties.URI(dMySQL, 'libmysql.dll'),
DatabaseProperties.DatabaseName,
DatabaseProperties.Username,
DatabaseProperties.Password );I assume I have to provide the name of the MySQL lib, 'libmysql.dll' to the function.
Now I get an EZSQLException with the message 'Requested database driver was not found'. In my code this exception is raised at this statement:
res := fDatabase.ExecuteInlined(aSQLQuery, true);aSQLQuery being a valid SQL statement.
If I inspect fDatabase, I see that fServerName is 'mysql'. Shouldn't this be
the name of the server where MySQL is running?
That did the trick.
Kudos for the fast response ...
Hi,
Has anybody come across this error before: EVariantTypeCastError : could not convert variant of type (UnicodeString) into type (Double)? I get this error when calling
JSONToDataset with this JSON string:
'[{"folio_id":11111,"folio_name":"testfolio 1","startDate":"2013-01-01","closedDate":"2013-01-02","description":null,"startCapital":null,"endCapital":null,"RiskValue":null},
{"folio_id":22222,"folio_name":"testfolio 2","startDate":"2013-01-01","closedDate":null,"description":null,"startCapital":null,"endCapital":null,"RiskValue":null}]'Whereas with this JSON the error is not raised:
'[{"folio_id":11111,"folio_name":"testfolio 1","startDate":"2013-01-01","closedDate":null,"description":null,"startCapital":null,"endCapital":null,"RiskValue":null},
{"folio_id":22222,"folio_name":"testfolio 2","startDate":"2013-01-01","closedDate":null,"description":null,"startCapital":null,"endCapital":null,"RiskValue":null}]'The only difference between the two JSON strings is "closedDate":"2013-01-02" and "closedDate":null. The error is raised when converting a to a DateTime field.
I am using the latest version of mORMot.
Regards,
Wai
Merci beaucoup for the tip. This one has put me on route again
.
Hi Arnaud,
I'm trying to use SynDBZeos to connect to a MySQL Database using the following:
fDatabase:TSQLDBConnectionProperties;
...
...
fDatabase := TSQLDBZEOSConnectionProperties.Create(ServerName, Databasename, Username, Password);
Servername is the hostname of the computer, Databasename is the databasename as created in MySQL, etc. etc.
The create seems to be executed without a problem, but when I get to 'res := fDatabase.ExecuteInlined(aSQLQuery, true);' I get a
EZSQLException with the message 'Requested Database driver was not found'. Apparently, it is unknown what the database is.
The question is, how do I provide the information to the constructor that the database is a MySQL database?
Cheers,
Wai
To connect a HTTP client I need to pass a TSQLModel as one of the arguments:
client := TSQLHTTPClient.create(ServerAddres, ServerPort, Model)
Can I simply pass nil as Model?
As for JSON, I will be using the JSONtoDataset routines.
Hi everyone,
I want to create a client that can consume webservices other than those created with the mORMot framwework. These
webservices communicates through JSON.
Is this possible and what steps do I need to take?
Thanks,
Wai
Hi Eraldo,
The solution is already explained in post #6 and #7 in this thread.
Cheers,
Wai
Guess I didn't read the small letters in the documentation :-).
Thanks for the info, Arnaud.
Cheers,
Wai
I just discovered that the following statements produces the error:
fTableJSON := fService.GetCountries;
aTable := TSQLTableJSON.Create([],'',pointer(fTableJSON),Length(fTableJSON));
TSQLTableToGrid.Create(StringGrid1, aTable,fClient);
DataSource1.DataSet := JSONToDataSet(Self, fTableJSON, fClient);
Whereas :
fTableJSON := fService.GetCountries;
DataSource1.DataSet := JSONToDataSet(Self, fTableJSON, fClient);
gives no error and produces the correct output i.e. the dbgrid connected to Datasource1 showing the
correct data.
I got the version from 26/3.
I just got the latest version from 27/3. Unfortunately, the error still get raised. Also the JSON message is incomplete. Instead of the previous
JSON message I now get : [{"Country_code
The JSON data looks like this:
[{"Country_code":"AUS","name":"Australia","currency":"AUD"},{"Country_code":"CAN","name":"Canada","currency":"CAD"},{"Country_code":"CN","name":"China","currency":"RMD"},{"Country_code":"DE","name":"Germany","currency":"EUR"},{"Country_code":"FR","name":"France","currency":"EUR"},{"Country_code":"HK","name":"Hong Kong ","currency":"HKD"},{"Country_code":"JP","name":"Japan","currency":"YEN"},{"Country_code":"NL","name":"The Netherlands","currency":"EUR"},{"Country_code":"UK","name":"Great Britain","currency":"PND"},{"Country_code":"US","name":"The United States of America","currency":"US"}]
I have also tried the code from example 16:
aTable := TSQLTableJSON.Create([],'',pointer(fTableJSON),Length(fTableJSON));
TSQLTableToGrid.Create(StringGrid1, aTable, fClient);
The data is displayed nicely in the grid.
Hi everyone,
I have this function as part of an interface (IStockPortfolio) on my server :
fDatabase: TSQLDBConnectionProperties;
function TStockPortfolio.GetSQLQueryResults(aSQLQuery:RawUTF8):RawJSON;
var
Res:ISQLDBRows;
begin
if fDatabase=nil then
ConnectDatabase;
res := fDatabase.ExecuteInlined(aSQLQuery, true);
if res=nil then
result := ''
else
result := res.FetchAllAsJSON(true);
end;
On the client, I would like to do the following:
fTableJSON := fService.GetSQLQueryResults('SELECT * FROM country');
DataSource1.DataSet := JSONToDataSet(Self, fTableJSON, fClient);
An EDatabaseError get raised in the JSONToDataset with message 'No fields defined. Cannot create dataset'.
What seems to be the problem here?
Any help much appreciated.
Cheers,
Wai
Hi Arnaud,
My compliments for the excellent mORMot Framework and the documentation.
Going through the SAD pdf document, what I missed the most in the functionality of the documentation is
the lack of hyperlinks in the documentation. I find it helpful to go deeper into a subject that I was reading and
be able to jump back.
Is there any chance some kind of a Wiki Doc being setup in the future?
Just my two cents ...
Thanks,
Wai