Recent

Author Topic: Lookup fields do not return data.  (Read 33174 times)

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Lookup fields do not return data.
« Reply #45 on: September 16, 2012, 11:12:38 am »
Stick with it!

I'm so desperate I'm considering booting windows for the first time in months to see if its any different there!  8-)

err, debugging it in windows 7 32bit so I would say no need to boot in windows.

For me evething works even an uncached lookup just doesn't show cell contents but does drop down and edit. Its only as soon as I enable look up cache

I'm seeing this with 64bit Laz 1.0 and 1.1 with fpc 2.6
on Ubuntu 12.04 using MySQL 5.1 connector or postgres connector....

I have a demo application that works with out a glitch with firebird and my schema.
At first I thought that something is wrong with the database and the message you get isn't related to the field at all, so I spend time making sure every field has the correct data type, that no constrain was bothering the process, etc. but with no lack.

After I gave up on setting up a correct debug environment yesterday I copied everything (DB, SQLDB, etc) in the applications directory and started debugging today. Didn't take much to find the following backward line.

Code: [Select]
procedure TField.RefreshLookupList;
var
  tmpActive: Boolean;
begin
  if not Assigned(FLookupDataSet) or (Length(FLookupKeyfields) = 0)
  or (Length(FLookupresultField) = 0) or (Length(FKeyFields) = 0) then
    Exit;
   
  tmpActive := FLookupDataSet.Active;
  try
    FLookupDataSet.Active := True;
    FFields.CheckFieldNames(FLookupKeyfields);//<-- this one makes no sense.
..........
end;

FFields is the fields collection that the field belongs to. it is set automatically when you call Dataset.fields.add(Myfield);
From a first look it should always link to the fields collection that this field is part of, aka PeopleQuery in this occasion. 

It makes no sense to try to find any kind of lookup fields in that collection. The problem is that my demo works and this makes no sense at all. I made sure that by changing the above line to
Code: [Select]
    FLookupDataSet.Fields.CheckFieldNames(FLookupKeyfields);
everything works as expected.

The search goes on. I need to find out why my demo works now.
« Last Edit: September 16, 2012, 11:14:17 am by taazz »
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

ludob

  • Hero Member
  • *****
  • Posts: 1173
Re: Lookup fields do not return data.
« Reply #46 on: September 16, 2012, 11:21:40 am »
Just tried your code on ubuntu 10.04 with the mysql 5.1 driver and your code runs fine with laz1.1 and fpc 2.7.1 after
- setting KeyFields and LookupKeyFields as I specified before
- adding
Code: [Select]
  titleQuery.Open;
  peopleQuery.Open;
to the FormCreate. Queries are not active in the OI!
- changing the table names to uppercase because of a bug introduced in sqldb mysql a while ago

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Lookup fields do not return data.
« Reply #47 on: September 16, 2012, 12:33:36 pm »
Just tried your code on ubuntu 10.04 with the mysql 5.1 driver and your code runs fine with laz1.1 and fpc 2.7.1.

Let me get this straight, the bug has been corrected in a newer version of fpc and we should upgrade to fpc 2.7.1? Do we have any time frame on when a new fpc will be released?
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Lookup fields do not return data.
« Reply #48 on: September 16, 2012, 01:19:25 pm »
And I found why my demo works. It seems that I had used a database that comes with the server to show case my problem and in both the queries I used there was a field name DEPT_NO had nothing to do with the lookup but that was enough to avoid the problem and work as expected.

Try to add a calculated field named TitleID in the peopleQuery that does nothing and you will be able to see results too.

Checked the SVN too, this one has been corrected there.
« Last Edit: September 16, 2012, 01:22:35 pm by taazz »
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

ludob

  • Hero Member
  • *****
  • Posts: 1173
Re: Lookup fields do not return data.
« Reply #49 on: September 16, 2012, 02:19:10 pm »
Quote
Let me get this straight, the bug has been corrected in a newer version of fpc and we should upgrade to fpc 2.7.1?
2.6.1 is working also. Not sure when this was solved.
Quote
Checked the SVN too, this one has been corrected there.
Was that the svn for lazarus or fpc? Where did you find the bug?

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Lookup fields do not return data.
« Reply #50 on: September 16, 2012, 02:31:30 pm »
Quote
Checked the SVN too, this one has been corrected there.
Was that the svn for lazarus or fpc? Where did you find the bug?
I found the bug on a clean lazarus 1.0 installation.
I Spend all day yesterday familiarizing my self with fpcup downloading and building from SVN. I checked my fpc\packages\fcl-db\src\base folders that fpcup downloaded and it was fixed. I assume that it hasn't re surfaced since.

I'm trying hard to stick with the released version so I can have some kind of control over my development, so far it has been proved pointless.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

codifies

  • Jr. Member
  • **
  • Posts: 98
    • bedroomcoders
Re: Lookup fields do not return data.
« Reply #51 on: September 16, 2012, 07:54:59 pm »
Wow guys thanks for all your Sterling work! Esp.. to taazz, above and beyond the call of duty!

Assuming I wish to keep as standard as possible and near to stable release as possible how should I best upgrade...

OR should I just work round the issue for the time being with a dummy field as taazz suggested and be patient and wait for stable...

Can't wait to get back to my laptop now....

Lazarus 2.3.0 r3945f73 FPC 3.2.0 x86_64-linux-gtk2

codifies

  • Jr. Member
  • **
  • Posts: 98
    • bedroomcoders
Re: Lookup fields do not return data.
« Reply #52 on: September 16, 2012, 08:23:26 pm »
Didn't take me long to get to a laptop !

I've got it working now with taazz's dummy field work-a-round
note also that it is necessary to keep both queries active properties to false and to
open them foreign table first order in the form create callback

thanks everyone! and taazz (*)
Lazarus 2.3.0 r3945f73 FPC 3.2.0 x86_64-linux-gtk2

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Lookup fields do not return data.
« Reply #53 on: September 16, 2012, 10:56:36 pm »
Personally I have moved to a snapshot version that comes with fpc 2.6.1 for my daily work it has less bugs and a shorter release cycle. I've updated to Lazarus-1.1-38674-fpc-2.6.1-20120916 today as well.
This will take care the problem for you.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

 

TinyPortal © 2005-2018