Relationship problem

A place for users and developers of the Xataface to discuss and receive support.

Relationship problem

Postby m23k » Wed Oct 31, 2012 7:36 am

Hi All

A bit of an odd one that has me scratching my head. I can update my users against computer with the computer_usage table fine. With mobile_usage though it always enters mobile_usage.person_id as 2 regardless of who I choose in pre-populated drop down of people? :(

I have the following tables (and some of the fields to give you an idea. 'id' is unique in each table):
Code: Select all
computer (id, make, model, sn)
computer_usage (id, computer_id, person_id, used_from_date, used_to_date)
mobile (id, make, model, imei)
mobile_usage (id, mobile_id, person_id, used_from_date, used_to_date)
person (id, firstname, surname)


My tables\computer\relationships.ini:
Code: Select all
[computer_usage]
action:label = "Users"
computer_usage.computer_id = computer.id
computer_usage.person_id = person.id


My tables\mobile\relationships.ini
Code: Select all
[mobile_usage]
action:label = "Users"
mobile_usage.mobile_id = mobile.id
mobile_usage.person_id = person.id
m23k
 
Posts: 19
Joined: Sun Oct 28, 2012 10:53 am

Re: Relationship problem

Postby m23k » Wed Oct 31, 2012 7:44 am

I've enabled history too and these aren't going in to the history table for this table. Is that correct/a bug?
m23k
 
Posts: 19
Joined: Sun Oct 28, 2012 10:53 am

Re: Relationship problem

Postby shannah » Wed Oct 31, 2012 7:48 am

Neither of these relationships specify a direct connection to the source table. Try changing the relationship definitions to:
Code: Select all
[computer_usage]
action:label = "Users"
computer_usage.computer_id = "$id"
computer_usage.person_id = person.id

and
Code: Select all
[mobile_usage]
action:label = "Users"
mobile_usage.mobile_id = "$id"
mobile_usage.person_id = person.id
--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: Relationship problem

Postby m23k » Wed Oct 31, 2012 8:04 am

You are right. Computer_usage is doing the same.

I had realised the "$id" bit actually and have just changed it, and saw your reply as I refreshed to post. Still broken though.

Code: Select all
[mobile_usage]
action:label = "Users"
mobile_usage.mobile_id = "$id"
mobile_usage.person_id = person.id


Now it used person_id=4 every time!
m23k
 
Posts: 19
Joined: Sun Oct 28, 2012 10:53 am

Re: Relationship problem

Postby m23k » Wed Oct 31, 2012 8:18 am

I might have not been clear: If I use 'add new xxx record' it works fine (person is created and the 2 records linked correctly). If I used 'add existing xxx record' the problems occurs where it just links to person with id 4 every time.
m23k
 
Posts: 19
Joined: Sun Oct 28, 2012 10:53 am

Re: Relationship problem

Postby m23k » Wed Oct 31, 2012 8:48 am

Got it! It just occurred to me from an earlier problem I had and fixed.

They all use 'id' for the field name. So I've renamed person.id to person.pid, computer.id to computer.cid, etc etc.

Is there a work around for this except renaming table fields so they don't match that of one in another table? I have a lot of fields repeated in different tables (I have startdate and enddate in both computer and mobile for example).

Thanks!
m23k
 
Posts: 19
Joined: Sun Oct 28, 2012 10:53 am

Re: Relationship problem

Postby shannah » Thu Nov 01, 2012 8:38 am

It should be able to handle duplicate column names in different tables. This may be a bug.
--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: Relationship problem

Postby m23k » Thu Nov 01, 2012 9:07 am

Sounds like it? Originally I had the problem with 2 fields called "used_from_date" and "use_to_date", so it isn't specific to the field name being "id". Having to rename fields as I try and do more and it produces problems.

Thanks
m23k
 
Posts: 19
Joined: Sun Oct 28, 2012 10:53 am

Re: Relationship problem

Postby m23k » Thu Nov 01, 2012 9:45 am

I think these are bugs too, not sure if I should report these in the offical 'Bug Tracker' at the top with more details? Just say :)

Say I'm on a specific computer record, looking at my person (user) list (relationship list between computer_usage, computer id, and person id). I then want to add a new person to this computer and I use 'add existing xxxx record' to choose an existing person. The history table for computer_usage does not get populated with the action of the new entry to the computer_usage table (row id, person id, computer id, date from, date to) that has just been added though. If I use 'add new xxx record' and create a new person, it does add an entry though. Either way a new row is being created in the computer usage table and surely history should be getting updated in bother situations?

Secondly, when on the 'history' tab, the 'users' tab also stays the 'in use' colour and you can not click/activate the link. Well it appears you can't. Looking closer at it, it is because the 'user' tab now has the same url as the 'history' tab.

Thanks
Keep it up :)
m23k
 
Posts: 19
Joined: Sun Oct 28, 2012 10:53 am


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 5 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved