You are not logged in.
Pages: 1
This is a sqlite limitation.
I see. Thanks!
Very nice! Thanks for your effort
I have made it to work. Just want to make sure if I was doing right:-
In order to use MSSQL in ORM way, I must create an Embedded Sqlite3 DB as a bridge, and map each Sqlite3 table as virtual table to MSSQL Physical Table by VirtualTableExternalRegister()?
If it is the case, the virtual tables on Sqlite3 can be come from different back-end database servers? Can the Begin/End Transaction still work?
If you use SQLite as the backend databae, SQLite itself doesn't support renaming a field.
Assume you have TSQLOldTable, now create a new class called TSQLNewTable with the new field definitions, call CreateMissingTables(); Then read old records from TSQLOldTable and add to TSQLNewTable;
drop tale TSQLOldTable.
Then change all references to TSQLOldTable in your code to TSQLNewTable.
Very thanks!
As I am new to the framework, do I have to copy the table by looping read/write progress, or there is a more effective way provided from the framework?
Renaming table/field name in Object definition just create new table/field. Changing field type, say change Integer to RawUTF8, gave nothing happen at all.
What is the correct way to do this? I read from other post someone execute "Alter Table" before CreateMissingTables(). Is it the correct way? Thanks!
I see. Thank you!
You can use DocVariantData(v.result.data).Value['1000'].
I just added the aDocVariant.Value(aName) and aDocVariant._(aName) pseudo methods, which can be used with late-binding.
So that now you can write also: v.result.data.Value('1000') since v.result.data.1000 won't compile.
See http://synopse.info/fossil/info/47805bc15e118
Really cool, thanks very much!
say v := _JSON('{result:{data:{"1000":"D1", "1001":"D2",..........
v.result and v.result.data return properly.
v.result.data.Exists('1000') returned True. Of course there is no v.result.data.1000 syntax.
How to get the value of key '1000'?
Thanks!
Sorry, I have overlooked your words: " stored not as string/UnicodeString by as RawUTF8", the Chinese chars were reserved when I consumed them, although they looks corrupted when I investigate the variant content.
But the With BOM problem still persists.
Why are you using a TStringStream here?
Just use
v := _jsonfast(StringFromFile('something.json'));
It will be just faster and less error-prone.
For streaming pure UTF-8 content, I would rather use our TRawByteStringStream.
It will avoid any slow conversion to UTF-16 as with the regular TStringStream.Within the TDocVariant, be aware that the UTF-8 content is stored not as string/UnicodeString by as RawUTF8.
But it should preserve the Chinese characters as expected.
Thanks! v := _jsonfast(StringFromFile('something.json')); is more concise.
However, the Chinese chars are still corrupted. My test results were:
1. if the JSON file is UTF8 encoded WITH BOM, v is unassigned. Seems error occurred.
2. if the JSON file is UTF8 encoded WITHOUT BOM, v stored the JSON correctly with the Chinese chars corrupted.
(I used Notepad++ to change the encoding of the JSON file, and I am using Delphi XE)
In case you want to take a try, this are my characters inside the JSON file:
{"msg":"","success":true,"result":{"data":{"1000":["垛","垜"],"1001":["坨","垚"]}}}
The 1.18 SAD PDF has a full per-unit help description.
Take a look at TDocVariant in the SAD.
See also http://blog.synopse.info/post/2014/02/2 … riant-type
Thanks for the info and I could make it work now. However, I run into an encoding problem:
var
v: variant;
begin
with TStringStream.Create('', TEncoding.UTF8) do
try
LoadFromFile('something.json');
memo1.Lines.text := DataString;
v := _json(DataString);
//v := _json(StringToUTF8(DataString));
finally
free;
end;
I have the JSON file that was UTF8 encoded, so I created the TStringStream with UTF8 encoding and display it firstly inside a Memo in order to make sure the encoding was correct.
No matter I added StringToUTF8/UTF8ToString or not, the variant resulted from _json corrupted my Chinese characters.
What should I do please?
I am still playing around with mORMot framework........amazing framework....
I have heavily used SuperObject for JSON manipulation. Now I want to study the JSON features of mORMot and found there is no separate Class Reference or Help file.
Anyway I have looked into the SAD document and tried to find a JSON function equivalent to TSuperObject.ParseString(). Maybe I had overlooked, I only found functions which require passing TypeInfo (i.e. know the JSON structure beforehand) or found xxxxxRead() functions that could read JSON string saved by xxxxSave() functions.
Say the JSON string returned from our server has many levels depth, and I just want the data started from level 3 with field name "data". I don't want to build a big Record structure before I can use just the sub-sub-sub Record field, like the RecordLoadJSON().
So, which function can read a random JSON string into a mORMot JSON object? Thanks!
Very nice, thanks for the info
I have gone through all the samples, it is absolutely cool and very useful framework.
Just wondering, if possible, how to consume the interfaced service like ICalculator, for example, from Delphi Prism, C# and Javascript? Or I must made the service RESTful if it maybe called by language other than Delphi?
Thanks!
Really thanks for fast response.
Was trying to delete this thread. I found I have another sqllite objects on searching path earlier than mORMot. It has been fixed. Thanks!
Hello, again.
I have tried out sample 2 and got AV error at
TSQLRestServerDB(Form1.Database).CreateMissingTables(0);
I used 1.18 NightlyBuild and had downloaded sqlite3.obj and sqlite3fts3.obj (sqlite3obj.7z) from your website to the mORMot source directory.
Please help.
Sorry, it's my fault.
I traced and found the JSON file, I was accidentally clicked "Add" when the message box was " Not Found". Even I add other "Hello"s, it returned only the first one.
Hello,
Just downloaded mORMot and gave it a try, the "01 - In Memory ORM" example.
It worked properly except when the Name is "hello"
TSQLSampleRecord = class(TSQLRecord)
private
fQuestion: RawUTF8;
fName: RawUTF8;
fTime: TModTime;
published
property Time: TModTime read fTime write fTime;
property Name: RawUTF8 read fName write fName;
property Question: RawUTF8 read fQuestion write fQuestion;
end;
Rec := TSQLSampleRecord.Create(Database,'Name=?',[StringToUTF8(NameEdit.Text)]);
i.e. As log as NameEdit.Text = 'Hello', the record could not be found. Why so strange?
Pages: 1