[fpc-pascal] SqlDB vs Zeos: TDataset.FieldDefs[].Size
LacaK
lacak at zoznam.sk
Mon Apr 22 10:24:53 CEST 2013
Graeme Geldenhuys wrote / napĂsal(a):
> On 2013-04-20 10:11, Ludo Brands wrote:
>
>> TFieldDef.Size is expressed in bytes. Zeos, IIRC, assumes a conversion
>> from any charset to utf8 could be made. Since UTF8 is up to 4 bytes per
>> char, a VarChar(10) can need up to 40 bytes to be represented in the
>>
>
> I assumed it has something to do with Unicode, but because I never
> specified a text encoding for the database when I created it - this
> confused me.
>
> I would have imagined that there might be two "size" properties.
>
Yes like in case of TField, where is (for ftString):
Size: max.length in characters used in f.e. DB-aware controls
DataSize: max.length in bytes used f.e. for allocating buffer size in record
> 1) .Size - which is the same value as specified in the DDL scripts
>
> 2) .DataSize - which might be larger than .Size in the case of Unicode
> encoded database.
>
> The problem I have with Zeos, is that I can't limit my text input in GUI
> applications now... Normally the .Size property would have been used,
> but now Zeos reports 4x the size, so all varchar(10) fields now look
> like they can store 40 characters, instead of only 10.
>
>
It is known pain, that causes either:
A.) you have enought long buffer, but then DB-aware MaxLength is incorrect
or
B.) you have correct MaxLength, but data are truncated
It leads me to thinking, that there is need for extend TFieldDef with
DataSize just like in TField
(and make DataSize independent from Size ... now are they related:
DataSize:=Size+1 ... so for SBCS it can be as now and for Unicede
encodings it can be fe: DataSize:=Size*4+1;)
-Laco.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20130422/3a1c5054/attachment.html>
More information about the fpc-pascal
mailing list