You are not logged in.
Pages: 1
Would you mind making the CopyRecord method of the TSQLRecord virtual so that i can override it?
Offline
I guess you spoke about the CreateCopy method (there is no such CopyRecord method)?
I'm not so fast to make TSQLRecord methods virtual, because each virtual method will use a pointer for every object instance.
I made some code refactoring so that every TSQLRecord has an Instance size of 20 bytes for private and protected fields (such as fID or fProps e.g.)... and I don't want this size to grow without imperial need.
Since I guess that this method won't be called often, I guess dynamic instead of virtual will be enough for you.
Virtual versus dynamic
Virtual and dynamic methods are semantically equivalent. They differ only in the implementation of method-call dispatching at runtime. Virtual methods optimize for speed, while dynamic methods optimize for code size.
In general, virtual methods are the most efficient way to implement polymorphic behavior. Dynamic methods are useful when a base class declares many overridable methods which are inherited by many descendant classes in an application, but only occasionally overridden.
So here is the patch:
http://synopse.info/fossil/info/37d5c99bf8
Just to be curious: what is it for?
Online
I was going to override the method because it did not copy blob fields.
Offline
I don't understand because in the current implementation, BLOB fields are copied.
The CreateCopy method copies all COPIABLE_FIELDS, i.e. all fields excluding tftMany (because those fields don't contain any data, but a TSQLRecordMany instance which allow to access to the data).
See
/// kind of fields which can be copied from one TSQLRecord instance to another
COPIABLE_FIELDS: TSQLFieldTypes =
[low(TSQLFieldType)..high(TSQLFieldType)] - [sftUnknown, sftMany];
So BLOB fields should be copied.... no need to override the method...
I've just made this CreateCopy method faster (using the new TPropInfo.CopyValue method).
Online
Hi Arnaud,
It seems that TSQLRecord.CreateCopy doesn't copy published properties of type TStrings?
Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.
Offline
Should be the case now thanks to http://synopse.info/fossil/info/744fef8868
Online
You are so quick, AB!
Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.
Offline
Pages: 1