Relationship field always compares false

Discussion of the version of HanDBase that runs on the iPhone and iPod touch devices. This includes the synchronization conduits as well.

Relationship field always compares false

Postby swus » Thu May 26, 2011 1:34 pm

I find that a Relationship field always compares false against a static value when used to define a Conditional field. Take these two databases:

DB: Colors
Fields: Item,Color
Values: sky,blue
Values: grass,green

DB: Blue Things
Fields: Item,Color,isBlue
Values: sky,blue,no
Values: grass,green,no

The fields in Colors are Text. The Color field in Blue Things is a Relationship keyed against Item in Colors. isBlue is a Conditional field defined to output "yes" when Color Is Equal To the static value "blue". For sky, it falls through to output "no". What am I doing wrong?
Ed Mooney
HanDBase for iPhone Version 4.9.063 | iOS Version 6.1.6
HanDBase for Android Version 4.6.316 | Android Version 4.2.2
swus
 
Posts: 7
Joined: Thu May 26, 2011 9:33 am

Re: Relationship field always compares false

Postby dhaupert » Fri May 27, 2011 9:15 am

What are the field types you have for each of the color fields? The field types must match or be stored in the same internal value for a relationship field to work. Let me know!
dhaupert
 
Posts: 4111
Joined: Tue May 26, 2009 11:51 am

Re: Relationship field always compares false

Postby swus » Sun May 29, 2011 1:45 pm

Thank you, Dave.

In the Colors DB, the Color field is Text. In the Blue Things DB, the Color field is a Relationship field keyed against the Item field in the Colors DB. Are you saying the Color field in the Blue Things DB needs to be a Text field in order to evaluate it against a static value as part of the definition for a Conditional field? If so, is there a way to convert the values in a Relationship field to Text?
Ed Mooney
HanDBase for iPhone Version 4.9.063 | iOS Version 6.1.6
HanDBase for Android Version 4.6.316 | Android Version 4.2.2
swus
 
Posts: 7
Joined: Thu May 26, 2011 9:33 am

Re: Relationship field always compares false

Postby dhaupert » Mon May 30, 2011 10:54 am

The field type that needs to match is the Item field you are referring in your relationship. For example, if the item field is an integer in one database and a text in another, the lookup won't find a match. This is done in an optimized way so the comparisons don't take too long. So the way the field is stored internally matters for those fields. What format is the item field in each table?
dhaupert
 
Posts: 4111
Joined: Tue May 26, 2009 11:51 am

Re: Relationship field always compares false

Postby swus » Wed Jun 01, 2011 8:50 am

Thank you, Dave.

The Item fields in both databases are Text. The Color field (a Relationship) in the Blue Things database is working fine: it shows the values from Colors database.

My issue is that, in the Blue Things database, the isBlue value for sky compares false. isBlue is a Conditional field that compares the Color value (blue, in the case of sky) with the static value "blue". I'm hoping the attached databases will help you see what, if anything, I'm doing wrong.
Attachments
swus.zip
Colors, Blue Things pdb files
(3 KiB) Downloaded 110 times
Ed Mooney
HanDBase for iPhone Version 4.9.063 | iOS Version 6.1.6
HanDBase for Android Version 4.6.316 | Android Version 4.2.2
swus
 
Posts: 7
Joined: Thu May 26, 2011 9:33 am

Re: Relationship field always compares false

Postby swus » Fri Jun 10, 2011 10:26 am

I'm blocked but thought I'd try one last time before moving on.

I have a database that depends on using a Conditional field to compare the value of a Relationship field with a static value. However, the comparison is always false, even when the Relationship field value is the same as the static value. Is this something I should be able to do with HanDBase or not?
Ed Mooney
HanDBase for iPhone Version 4.9.063 | iOS Version 6.1.6
HanDBase for Android Version 4.6.316 | Android Version 4.2.2
swus
 
Posts: 7
Joined: Thu May 26, 2011 9:33 am

Re: Relationship field always compares false

Postby dhaupert » Fri Jun 10, 2011 11:01 am

Hi Ed,

My apologies for the delayed response- I've been swamped with the 4.7.5 release and let the forum posts fall behind.

I can see where you'd be perplexed, as your database is all set up correctly based on how I'd (and you'd) think it should be done intuitively. Unfortunately a conditional field cannot compare the value in a relationship field. The reason for this is complex- the relationship field does not actually hold a value- wherever it's shown, a live lookup is done to the other database. The calculation routines when evaluating a conditional don't currently perform the lookup so a value of 0 is inferred, but they do it when the record is being saved.

I am attaching a slightly modified version of your Blue Things database. This version has an additional conditional field to get the relationship value into a field in this database. It's a silly field- it is set up that regardless of how the condition is evaluated the output is the relationship's value. Then the actually isBlue is evaluated based on that output.

The whole workaround is awkward and I agree that a conditional should be fixed to evaluate the relationship field in it's live mode so that your original database is right. As it is now, the record has to be saved before the conditional field is evaluated correctly. My apologies for this- I'm adding this to the todo list for a future version- hopefully this workaround will work for you in the interim!

Blue_Things.zip
(1.89 KiB) Downloaded 112 times
dhaupert
 
Posts: 4111
Joined: Tue May 26, 2009 11:51 am

Re: Relationship field always compares false

Postby swus » Fri Jun 10, 2011 2:59 pm

Hi Dave,

That's a completely acceptable workaround. Thank you for unblocking me and congratulations on shipping 4.7.5!
Ed Mooney
HanDBase for iPhone Version 4.9.063 | iOS Version 6.1.6
HanDBase for Android Version 4.6.316 | Android Version 4.2.2
swus
 
Posts: 7
Joined: Thu May 26, 2011 9:33 am

Re: Relationship field always compares false

Postby Treanot » Sat Mar 12, 2016 3:11 pm

Has the conditional field "live" updating been resolved? I'm having the same similar issue but I'm noticing that it a lack of feature.
Treanot
 
Posts: 39
Joined: Mon Feb 08, 2010 3:15 pm


Return to HanDBase for iPhone and iPod touch

Who is online

Users browsing this forum: No registered users and 2 guests