[fpc-devel] TFieldDef.Size vs TField.Size
Joost van der Sluis
joost at cnoc.nl
Thu Feb 24 14:55:00 CET 2011
On Thu, 2011-02-24 at 12:59 +0100, LacaK wrote:
> if you can inform about your plans, order of tasks etc. ... it will be
> welcomed
The order.. well, that's difficult.. What comes first, comes first. :)
> if I can help you, let me know ... for example I have fix for
> TODBCConnection.SetParameters ... there is missing ftTime and
> ftWideString,ftWideFixedChar cases ... as revealed by testing with
> ODBC/MySQL
I'm adding some ftTime tests. All widestring-issues are postponed until
I found a way to deal with them, unicode, and have tests to test them.
but now the TFmtBcd field is finally implemented, you can add support
for that? Now it only works with sqlite, maybe you can add it for the
other databases that you use? (odbc,mysql?)
> > As I wrote in the bug-report, TFieldDef.Size should contain the number
> > of bytes to hold the string, without the leading 0.
> >
> why do you think so ?
> If we do not care about Delphi documentation, it seems to me more
> consistent, that TFieldDef.Size and TField.Size says about equal
> things
It depends on how they are used. I think it is very usefull for a
programmer to know the maximum amount of characters. (TField.Size) And a
programmer should be able to detect how many bytes are reserverd to
store it (TFieldDef.Size).
This is especially important if we are supporting unicode-strings, where
both values can differ. So when you are getting/setting data from the
server, you use TFieldDef.Size, and then you want to check what the
maximum amount of characters is, TField.Size.
> > Note that with the unicode-versions of Delphi have in TFieldDef.Size the
> > amount of characters * 4 in TFieldDef.Size. For WideStrings and normal
> > strings.
> >
> > I'm thinking about adding a property to T(Buf)Dataset in which you can
> > specify if you want to use unicode-length strings, or 'normal' lengths.
> > So that we can add backwards-compatilibity, which Delphi doesn't.
> >
> would not be better add such property to TSQLConnection class, as IMO
> all SQLQueries connected to one DB will work with same type of
> strings. So users can set it once and not for every TCustomSQLQuery
> object individualy ?
Maybe. but I have to think about it better. Because if code in
fields.inc depends on it, we have to add the property to TDataset
itself.
> > So if you have a wide-string of
> > 40 characters. TFieldDef.Size is 160, but TField.Datasize 322.
> > (obviously wrong)
> >
> >
> Yes, TField.Size = TFieldDef.Size, TField.DataSize = (TField.Size+1)*2
There are more ways to solve that. And we need to find how the Delphi
datasets which do not have this problem do that.
One way is: TField.Size := (TFieldDef.Size div 2) if it's a WideString,
and div 4 if unicode is enabled. Or the TDataset descendant has to
correct the value for WideStrings when creating fields. (How?)
Joost.
More information about the fpc-devel
mailing list