[fpc-pascal] Master Detail relationship in SQLdb

Michael Van Canneyt michael at freepascal.org
Sun Jul 15 12:20:33 CEST 2007



On Sun, 15 Jul 2007, Joost van der Sluis wrote:

> On Sun, 2007-07-15 at 07:24 +0200, Martin Schreiber wrote:
> > On Sunday 15 July 2007 01.10, Joost van der Sluis wrote:
> 
> > > I have a question about the widestrings. I thought that tmsebufdataset
> > > handles all strings as widestrings. But I can't find any reference to
> > > that in the code. It would be silly anyways: from the db-engine you'll
> > > get 8-bytes based strings. And a ftString fields's .asString method will
> > > return a normal ansistring. The same holds for your code.
> > >
> > I needed to use my own TField descendants because I can not modify db.pp . See 
> > lib/common/msedb.pas, especially tmsestringfield, TField.GetClassDesc does 
> > not workfor them BTW.
> 
> It's very difficult to see what you do in msedb.pas. That's because it's
> (guess) about 80% fpc code. But then renamed and refactored. With some
> minor changes. And a few additions, offcourse. But it's diffucult to see
> what you really do, without digging in the code for hours.
> 
> > The strings are converted from utf8 or current locale encoding to UCS2 after 
> > fetching the data from database and to utf8 or current locale encoding before 
> > sending data to the database in order the string encoding needs not to be 
> > converted while displaying and editing data in MSEgui.
> 
> Ok, but a normal 'select * from table' generates a TDataset with regular
> TStringFields. And then no concersion takes place? Only if you
> specificly decide to use TMseStringField?

tmsebufdataset overrides getfieldclass:

  function  getfieldclass(fieldtype: tfieldtype): tfieldclass; override;

If we merge things, Martin can (and should) keep TMSESQLQuery as a descendent 
of TSQLQuery where he overrides getfieldclass so his own field types are used.
That's the beauty of OOP :-)

Michael.



More information about the fpc-pascal mailing list