You are not logged in.
Pages: 1
When retrieving a record with sample 4 the raw JSON response from the server is something like:
[{"ID":1,"Time":135192192214,"Name":"Tim","Question":"Hello world"}]
but if a record isn't found instead of an empty JSON array which I expected you get an object:
{"fieldCount":4,"values":["ID","Time","Name","Question"],"rowCount":0}
Is this right? It uses the ExecuteList function which line 12331 of mORMot.pas says "/// Execute directly a SQL statement, expecting a list of resutls"
Offline
I understand the different formats but sample 4 has NoAJAXJSON set to false so it should be using the expanded format. However, using EngineList on the client gets a response in the non expanded format if result is an empty list otherwise the response is expanded. This seems inconsistent.
Offline
Okay but I would prefer the expanded format to return just an empty array if the result is empty. Then a javascript client wouldn't have to do a typeof check to see if the result is an object or array. This could be done by removing lines 4185-4192 in SynSQLite3.pas:
if (result=0) and W.Expand then begin
// we want the field names at least, even with no data: we allow RowCount=0
W.Expand := false; // {"FieldCount":2,"Values":["col1","col2"]}
W.CancelAll;
for i := 0 to FieldCount-1 do
W.ColNames[i] := sqlite3.column_name(Request,i);
W.AddColumns;
end;
I can't see this breaking standard mORMot clients.
Offline
Would it be worth adding a separate built in function to return basic model info or just field names? It could be accessed with a URI such as http://host/root/tablename/fieldnames
Offline
I do not see any reason to remove this code.
This is not an issue, but a feature, needed by other users of the library (it was not my idea, but I did understand the point and found it interresting)!
Your AJAX client has to adapt to the format used, as official Delphi, FPC or SMS/AJAX clients do.
Use case is pretty easy to implement: if it does not return a JSON array, you can assume it contains no value. A single "if" in your client library.
For ORM information, you have every information already returned by mORMotWrapper.pas.
It is the same information used by the client wrappers.
Offline
And I guess "if" can be an error. Thanks
Offline
Pages: 1