Page 1 of 1

A few TZMemTable remarks

Posted: 29.01.2021, 20:57
by aehimself
Hello,

Just a few remarks for the new TZMemTable component:

- ftMemo, ftString, ftFixedChar will throw a nullpointer exception upon opening:

Code: Select all

 ZMemTable1.FieldDefs.Add('MyField', ftString);
 ZMemTable1.Open;
Issue is in ZMemTable.pas : 208

Code: Select all

        else if Current.DataType in [ftMemo, ftString, ftFixedChar] then
          ColumnInfo.ColumnCodePage := GetTransliterateCodePage(Connection.ControlsCodePage)
TZMemTable has no connection, so Connection.ControlsCodePage is referring to nil.ControlsCodePage. Lines 208 and 209 can be deleted, items can be merged with the next condition:

Code: Select all

        else if Current.DataType in [{$IFDEF WITH_FTWIDEMEMO}ftWideMemo, {$ENDIF}
          ftWideString{$IFDEF WITH_FTFIXEDWIDECHAR}, ftFixedWideChar{$ENDIF}, ftMemo, ftString, ftFixedChar] then
          ColumnInfo.ColumnCodePage := zCP_UTF16;

- The above also renders the condition in : 217 useless, as it will never be true:

Code: Select all

    if (Connection <> nil) and (Connection.Connected)
    then AConSettings := Connection.DbcConnection.GetConSettings
I created a small patch with the above, will issue a pull request soon.


With that said, I have the following code:

Code: Select all

 ZMemTable1.FieldDefs.Add('MyField', ftString);
 ZMemTable1.Open;
 ZMemTable1.Append;
 ZMemTable1.FieldByName('MyField').AsString := 'Hello, world!';
 ZMemTable1.Post;
I have a DataSource and a DBGrid connected, and it is showing that 'MyField' is WideMemo instead of String, which I explicitly created:

The reason is, ConvertDbcToDatasetType sets the fieldtype as WideMemo, if there is no length specified. I can see the reason, just want to ask if it is intended?

Code: Select all

ZMemTable1.FieldDefs.Add('MyField', ftString, 200);
Works as planned.

Re: A few TZMemTable remarks

Posted: 05.02.2021, 06:25
by EgonHugeist
Thanks for the feedback!
As my commit says: it was a 20 min job :P
I found some more inconsistencies in other components too
  • TZStoredProc has an UpdatSQL property
  • TZStoredProc has no Transaction property
  • TZStoredProc has OnPostError Event property
  • TZMemTable has an UpdatSQL property
  • TZMemTable has OnPostError Event property
Just to name some i have seen. :roll:. That than meens there is an issue with the alltime inheritance model of some of the components.
According the AV's thanks for the temporary fix. Using the W-Fields hides theses issues. I'am working on it, including a connection property for TZMemTable.
aehimself wrote: 29.01.2021, 20:57 The reason is, ConvertDbcToDatasetType sets the fieldtype as WideMemo, if there is no length specified. I can see the reason, just want to ask if it is intended?
Yes it is. The TString/WideString-Field need a size for a buffer. Otherwise you would get an exception on creating the fields.

Re: A few TZMemTable remarks

Posted: 05.02.2021, 08:25
by aehimself
EgonHugeist wrote: 05.02.2021, 06:25 Thanks for the feedback!
As my commit says: it was a 20 min job :P
...and you can't imagine how happy your 20 minutes made us, end users :)
There were lots of people waiting for this feature, so yeah, thank you again!
I already included it in one of my projects, replacing an in-memory SQLite connection :)
EgonHugeist wrote: 05.02.2021, 06:25I'am working on it, including a connection property for TZMemTable.
Does it need one? Or it'll be optional? In my view the main advantage of a memtable that it is 100% functional without a connection and therefore can be used to de- and reconstruct data tables from any source.

Re: A few TZMemTable remarks

Posted: 05.02.2021, 09:23
by miab3
The most important are the methods of copying (with filtration) and even better using SQL (but it's already pretty high-grade stuff) from and to local sources(datasets). Some do this by putting SQLite underneath.

Michał

Re: A few TZMemTable remarks

Posted: 11.02.2021, 05:33
by brick08
Hallo. I will also add.
In TZMemTable when displaying fields of type TZRawStringField, the program gives an error AV. See screenshot.

Re: A few TZMemTable remarks

Posted: 11.02.2021, 09:43
by aehimself

Re: A few TZMemTable remarks

Posted: 12.02.2021, 05:53
by EgonHugeist
EgonHugeist wrote: 05.02.2021, 06:25 Does it need one? Or it'll be optional? In my view the main advantage of a memtable that it is 100% functional without a connection and therefore can be used to de- and reconstruct data tables from any source.
No it does not "need" a connection. I just added it to inherit the ControlsCodepage and the Formatsettings from the connection component. That's all.

Brick08 any news on this?

Re: A few TZMemTable remarks

Posted: 15.02.2021, 12:02
by brick08
EgonHugeist wrote: 12.02.2021, 05:53 Brick08 any news on this?
Now it's ok, thanks.