Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2005-03

TField.IsNull for Interbase (or rather Firebird :) implemented

4 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Michalis Kamburelis

Hi

I managed to implement correct TField.IsNull behaviour for fields inside TIBQuery dataset. I'm attaching:

-- patch to packages/base/ibase/ibase60types.inc, this fixes a small bug in ibase60 unit that defined Short as Integer (= 32 bits, since ibase60 unit is compiled in objfpc mode), while it should be 16 bits.

-- patch to fcl/db/interbase/interbase.pp that

1) Fixes FFieldFlag declaration, it should be an array of IBase60.Short type (16 bits, not 8-bits ShortInt type as it was).

2) Implements correct TField.IsNull behaviour by recording "IsNull" state of each field of each record, along with data of that field. ThenTIBQuery.GetFieldData can be modified to return correct value of IsNull, and set Buffer^ only if field is not null and Buffer nil (since TField.GetIsNull calls TField.GetData with Buffer = Nil, and this causes call to FDataset.GetFieldData with Buffer = nil)

3) Oh, and small changes to TIBTransaction that I sent in my previous email this day (publishing 4 properties) are also included in this patch. Sorry, this was just easier for me, and since I didn't see them committed yet... Anyway, these changes to TIBTransaction are absolutely not related to all that "IsNull stuff", so feel free to cut them out if you don't like them.

-- I'm also attaching a trivial program using Interbase unit and some testing db to check that IsNull works as it should. Just in case it will save you some time in testing my patch :)

Michalis.

Reply by email

Michael Van Canneyt
to Michalis Kamburelis
Michalis Kamburelis wrote 30 lines
Hi I managed to implement correct TField.IsNull behaviour for fields inside TIBQuery dataset. I'm attaching: -- patch to packages/base/ibase/ibase60types.inc, this fixes a small bug in ibase60 unit that defined Short as Integer (= 32 bits, since ibase60 unit is compiled in objfpc mode), while it should be 16 bits. -- patch to fcl/db/interbase/interbase.pp that 1) Fixes FFieldFlag declaration, it should be an array of IBase60.Short type (16 bits, not 8-bits ShortInt type as it was). 2) Implements correct TField.IsNull behaviour by recording "IsNull" state of each field of each record, along with data of that field. ThenTIBQuery.GetFieldData can be modified to return correct value of IsNull, and set Buffer^ only if field is not null and Buffer nil (since TField.GetIsNull calls TField.GetData with Buffer = Nil, and this causes call to FDataset.GetFieldData with Buffer = nil) 3) Oh, and small changes to TIBTransaction that I sent in my previous email this day (publishing 4 properties) are also included in this patch. Sorry, this was just easier for me, and since I didn't see them committed yet... Anyway, these changes to TIBTransaction are absolutely not related to all that "IsNull stuff", so feel free to cut them out if you don't like them. -- I'm also attaching a trivial program using Interbase unit and some testing db to check that IsNull works as it should. Just in case it will save you some time in testing my patch :)

Patch applied, thank you very much. I skipped the test, though. Flames will be redirected to you ;)

Michael.

Reply by email

Joost van der Sluis
to Michalis Kamburelis: Hi I managed to implement correct TField.IsNull behaviour for fields inside TIBQuery…
I managed to implement correct TField.IsNull behaviour for fields inside TIBQuery dataset. I'm attaching:

Good work.

But I want to mention that the sqldb-TSQLQuery firebird component is a simple copy of TIBQuery, but in that one the .IsNull was already implemented. I could had backported that one, if you'd asked.

I'll look at your solution this weekend, maybe I can use some of it in TSQLQuery.

Met vriendelijke groeten, Joost van der Sluis CNOC Informatiesystemen en Netwerken http://www.cnoc.nl

Reply by email

Michalis Kamburelis
to Joost van der Sluis
Joost van der Sluis wrote 14 lines
>I managed to implement correct TField.IsNull behaviour for fields inside >TIBQuery dataset. I'm attaching: Good work. But I want to mention that the sqldb-TSQLQuery firebird component is a simple copy of TIBQuery, but in that one the .IsNull was already implemented. I could had backported that one, if you'd asked. I'll look at your solution this weekend, maybe I can use some of it in TSQLQuery.

Believe it or not, but I simply missed the fact that there is another Firebird dataset implemented inside sqldb. Now I looked what I have available in sqldb and I'm quite impressed -- especially nice PostgreSQL dataset is something I wanted to have for some time. So thanks for info, in the future I think that I will use datasets from sqldb.

Michalis.

Reply by email