You are not logged in.
OK, I was out and reading the docs without a computer to test when posting this question ![]()
Now just tested it, after calling TSQLDBSQLite3ConnectionProperties.MainConnection.Connect the db file will be auto created.
I've just started using direct SQLite db access (with TSQLDBSQLite3ConnectionProperties,TSQLDBSQLite3Connection and so on), without using the ORM layer.
The the db file is not existing yet, does TSQLDBSQLite3ConnectionProperties.Create auto creates the db file?
If not, how to create the db file?
Thanks.
So the units are included twice?
No, just once, in the build-first package. As we know, a unit can only be included in one package.
So I found a solution for this issue.
According to the document: E2201 Need imported data reference ($G) to access '%s' from unit '%s' (Delphi)
The solution is to add the units that are missing imported data reference to the build-first package (which has the {$IMPORTEDDATA ON} directive).
For example, the following error is what I got today:
[dcc32 Error] E2201 Need imported data reference ($G) to access 'crcblock' from unit 'SynCrypto'
[dcc32 Error] E2201 Need imported data reference ($G) to access 'FillcharFast' from unit 'mORMot'The solution was to add both SynCrypto.pas and mORMot.pas to my package that's supposed to be built and installed first.
Thanks, it works now.
Sometimes we have to bear with the Delphi compiler bugs/limitations, unfortunately...
I always use Google search instead of the search function provided by **any** forum software - how a forum software can beat the big G in terms of text searching ![]()
An interesting discussion about an open source project for replicating SQLite:
LiteFS a FUSE-based file system for replicating SQLite (https://github.com/superfly/litefs)
Maybe put all the code in a github repository?
I know TDocVariant.NewFast is faster, but I'm still not very sure about when to use TDocVariant.NewFast or TDocVariant.New.
From the manual:
- by default, every internal value will be copied, so access of nested properties can be slow - if
you expect the data to be read-only or not propagated into another place, set
Options=[dvoValueCopiedByReference] will increase the process speed a lot
- in practice, you should better use _Obj()/_ObjFast() _Arr()/_ArrFast() functions or
TDocVariant.NewFast()
The obscure part is this:
if you expect the data to be read-only or not propagated into another place...
My json is not read-only, but what does "not propagated into another place" mean?
Thanks.
Oh I see.
masterJson.MyArray := arrayVar; equals to:
_Safe(masterJson).Value['MyArray'] := arrayVar;Read the docs again and experimented again, I found that there are actually several ways to add an array of json objects to another json object
Thanks!
@ab,
I'm constructing a json object consists array of json objects, like the following:
{
"MyItems":
[
{
"FileName": "111.txt",
"Position": 0
},
{
"FileName": "abc.exe",
"Position": 1
}
]
}Code for testing, and the 2 questions are written in the comments
procedure TForm4.btnTestAddArrayClick(Sender: TObject);
var
i: Integer;
itemVar: Variant;
arrayVar: Variant;
masterJson: Variant;
begin
TDocVariant.New(arrayVar);
TDocVariant.New(itemVar);
TDocVariant.New(masterJson);
for i := 0 to 1 do
begin
itemVar.FileName := 'file' + IntToStr(i);
itemVar.Position := i;
_Safe(arrayVar).AddItem(itemVar); // is there a better method for adding array item here?
end;
// the following two calls will cause 'Variant method calls not supported.' error, why?
// masterJson.AddOrUpdateValue('ProjectItems', arrayVar);
// masterJson.Value['ProjectItems'] := arrayVar;
_Safe(masterJson).Value['MyArray'] := arrayVar; // ok
ShowMessage(JSONReformat(VariantSaveJSON(masterJson)));
end;Thanks for your help in advance!
That's how a great library gets popularized. Well done, tbo!
Is it about mORMot 1 or mORMot 2?
Great job and congratulations!
no problem, just providing the info.
Please also note that there are two types of comments:
- "zip file comment" and,
- "comment of a file inside the zip file".
Does TZipWrite support adding comments to the zip file?
Thanks, I found it.
Maybe an "Upgrade notes for mORMot 1 users" blog post is enough to get us start upgrading ![]()
Re. examples, I just pulled the latest source and found "\ex\ThirdPartyDemos\martin-doyle", I guess those samples done by Martin Doyle can already get me started.
That being said, based on your statement it seems that mORMot2 is stable for my use cases, so I might start using it instead of v1 for a new project.
I main sqlite db tool is https://sqlitestudio.pl/
I've tried many in the past this one is the best IMHO.
Found it over the weekend:
https://github.com/little-brother/sqlite-gui
It's written in c, very small in size, but seem to have enough function to be useful.
@ab,
I think both routing syntax is OK as long as it's flexible enough and can also route to a method-based service ![]()
@ab,
Another ideaHttpServer.Route('$/$/overview', 'http://dynamicserver1.net/restroot/overview?lng=$&product=$');Converting httpserver to proxy/gateway where dynamicserver1.net can dynamically add route to httpserver on start.
I know this is more complex change. Just idea.
If what you are proposing is possible with mORMot, when we can write a 'load balancer' with mORMot? ![]()
@ab,
What your proposed above for mORMot2 is a very clean but useful idea I think! And it just meets the requirement I suggested above.
Or you have the THttpServerGeneric.OnBeforeRequest event which allows to change the URI on the fly before it is actually sent to the REST server(s).
I have just made THttpServerRequest URI/Method fields writable - could be customized in this OnBeforeRequest event handler.
See https://synopse.info/fossil/info/02c03e4147
and https://github.com/synopse/mORMot2/commit/898858e9I did not test this method, but I guess this is soon enough to customize whatever input you need, and make internal redirection.
Thanks! From what I read and understand, I think the changes will help achieve the URL directing I want.
Why not make language a root, so you'll have en root and de root?
Because everything about the languages and product names are dynamic.
You can with nginx, I don't use IIS. I don't know why you would want to remove method name, with mORMot you can dynamically link a method to any string using TRestServer.ServiceMethodRegister(...).
Consider a website that's mostly for representing products and you might have the following pages:
http://server.com/en/product1/overview
http://server.com/en/product1/reviews
...
http://server.com/de/product2/overview
http://server.com/de/product2/reviews
The URIs above is obviously cleaner than something like:
http://server.com/root/www/en/product1/overview
And that's why I want to remove both the root name uri and method name (www in the above example) in this case.
Hope it makes sense.
ok, maybe pvn is right, to handle it with the reverse proxy like IIS or nginx.
I guess the reverse proxy can also hide the method name? I mean, currently for method-based service in mORMot, the URI will be like:
http://server.com/root/methodname
Can I remove both the root and method name? I use IIS and I wonder if can point to to some technical article or tell me which keywords to use for googling ![]()
@ab, Can overriding TSQLRestServerURIContext.URIDecodeREST retrieve the following URI resolving?
http://server.com/[language]/[companyname]/[contact or teams or overview]?
Note, there is no root nor method name are specified in the above URI.
If not, how can I achieve the above URI resolving? Thanks.
@tihory,
From your description I guess you might have misunderstood the batch updating mode in mORMot.
Basically, it's a cache you put your updated, deleted or newly added records in a **cache**, then send all the data in a single shot.
I don't use Postgresql with mORMot, so couldn't comment.
I would 100% expect tortoise to not auto overwrite your modifications if the two conflicted. Maybe you encountered a bug like you said but this just sounds normal operation to me.
Actually my manual changes to the SynCommons.pas file were not shown in the above screenshot at all, my changes were in other lines, all are similar to:
//{$define DOPATCHDISPINVOKE}these change of mine are not shown in the above screenshot.
So I'm 100% sure the code differences shown in the above screenshot were not done by me ![]()
The commit in the above screenshot is indeed a real commit, https://github.com/synopse/mORMot/commi … 0717d58c5a
Yes, I knew it's a real commit, what I said I don't know is why svn didn't merge it correctly ![]()
PS, may this case of mine can be listed in that kind of "what strange bugs you've experienced" article ![]()
Nice that you found out why but it really isn't the tools fault, there was clearly a conflict with your manual changes.
Thanks for your comments, but no no no, the code differences as shown in the screenshot I posted above IS NOT my manual changes, I did not change those two lines.
I actually don't know why the code differences existed, my changes were located in other 3 lines related to the `DOPATCHTRTL` definition. The screenshot above was captured after I synced my changes to the latest downloaded source and only leaving the mysterious code differences as shown in the screenshot.
sorry I didn't make it clear.
Wow! Unbelievable! The issue is neither coming from the mORMot code nor my code, it's an issue of TortoiseSVN - I use TortoiseSVN to download latest mORMot source from github and since I've done minor changes in SynCommons.pas, it somehow failed to update/merge that file. See attached screenshot.
I think I should now switch to a real git client to pull public code, but I really like TortoiseSVN shows what files were changed/added after executing the "Update" command.
OK, I'm getting the following error:
Project My_Server.exe raised exception class EORMBatchException with message 'TDbServer.EngineBatchSend: Unknown @GeneralEvent'.
Where GeneralEvent is a table name.
Strange, I check the project's svn logs and there is no recent changes, but just updated mORMot. But I don't know where and the old mORMot revsion. I think now I should have a text file for recording each time I pull the latest mORMot source to local...
ok, another related issue must be related - in a project that's not using the mORMot authentication (aHandleUserAuthentication is False for TSQLRestServerDB.Create), the batch update operation is no longer allowed - BatchSend returns HTTP_FORBIDDEN 403
I will now have to check mORMot commit logs one by one to determine which revision changed the behavior...
ok, Since I use the default 'User' user, I guess it has something to do with the fact that in `TSQLAuthGroup.InitializeTable`, it excludes the `reSQLSelectWithoutTable` attribute:
...
Exclude(A.AllowRemoteExecute,reSQLSelectWithoutTable);
...@ab,
I'm using `ExecuteList` without supplying the `Tables` parameter, something like:
myDbClient.ExecuteList([], 'select...')Both the client and the server has been running ok for years (the mORMot version was last years), but recently after upgraded to the latest mORMot, the client is getting 'Method Not Allowed' errors, but I couldn't identify since which revision of mORMot the issue is start raising.
Does it have anything to do with reSQLSelectWithoutTable or TSQLAllowRemoteExecute? Please advise how to make ExecuteList work without supplying the `Tables` parameter. Thanks.
In short, postlite sits between a Postgres database management GUI tool and a SQLite db.
https://github.com/benbjohnson/postlite
But I'm afraid it won't support dbs created by mORMot since mORMot uses custom collations...pity..
What do you think @ab?
First time heard of the `sqlite3_interrupt` function, it seems to be very helpful!
@ab,
Oh I see, you are professional in this area, and I only look at the description.
@ab,
Just an idea - in case you are interested, this is a new Base64 encoder which you can include in any benchmark ![]()
Great! Downloading ![]()
Thanks for your great job, as aways!
You can now query JSON stored in a table like this:
select id, name, interests from user
where interests->'likes'->>'[0]' = 'skating';It's very convenient!
More details: https://tirkarthi.github.io/programming … ments.html
@MPV,
Sorry to hear about that, take care of yourself and your family and stay safe!
Great! Thanks for clarifying things.
Great news!
@ab, one suggestion - while new projects should use mORMot2, there might be old projects that'll keep using mORMot1.
So the question is - will it possible to use both mORMot v1 and v2 in the same time? Even in the same project?