Related Table Erroneous Entries

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

Related Table Erroneous Entries

Postby simb » Wed Oct 24, 2012 10:24 am

Hi Steve and forum members,

I hope someone can shed light on __keys__[id] a hidden field which is passed when submitting a form.

The issue we are facing is that in a related table arrangement, the __keys__[id] at some random point in time do not match the actual id of the table. As a result the related data which gets entered is for a wrong parent record.

Here is the source view of the page before submission:

<input name="__keys__[id]" type="hidden" value="730" />
<input name="-table" type="hidden" value="tbl_application" />
<input name="-relationship" type="hidden" value="trc" />
<input name="-action" type="hidden" value="new_related_record" />
<input name="-table" type="hidden" value="tbl_application" />
<input name="-action" type="hidden" value="new_related_record" />
<input name="-limit" type="hidden" value="200" />
<input name="-cursor" type="hidden" value="202" />
<input name="-skip" type="hidden" value="200" />
<input name="-mode" type="hidden" value="browse" />
<input name="-recordid" type="hidden" value="tbl_application?id=729" />
<input name="-relationship" type="hidden" value="trc" />
<input name="--original_action" type="hidden" value="new_related_record" />
<input name="-query" type="hidden" value="-table=tbl_application&amp;-action=new_related_record&amp;-limit=200&amp;-cursor=202&amp;-skip=200&amp;-mode=list&amp;rfaId=%3D4&amp;status=%3DComplete&amp;-recordid=tbl_application%3Fid%3D729&amp;-relationship=trc" />

The actual value that should have been passed is 729 but what is passed is 730 ( __keys__[id]) and as a result the data gets entered in the wrong parent record. Really scratching my head and there just does not seem to be a logical answer to this - Did not change the code etc, every thing was working just a few days ago and the recurrence of the event is more than can be safely ignored. Currently handling this in beforeInsert when I manually check the values and if they are different, exit gracefully. This happens in all related tables and with admin as well other roles.

Any pointers will be highly appreciated,
Looking forward -
Thanks!
simb
 
Posts: 4
Joined: Wed Oct 24, 2012 10:07 am

Re: Related Table Erroneous Entries

Postby shannah » Fri Oct 26, 2012 9:05 am

Can you post some more information. E.g. the relevant relationships.ini definition and table definitions?
Also, what version of Xataface are you using?
--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: Related Table Erroneous Entries

Postby simb » Fri Oct 26, 2012 9:43 am

Hi Shahnah,

xataface version is 1.3.2

The parent table is "tbl_application" and has "id" as a primary, auto increment field.
The child table is "trc" and has a filed "applicationId" which refrences the parent (tbl_application) id in FK relation ship.
The tables are linked in a one to many arrangement.

The relationship.ini includes:

[trc]
trc.applicationId = "$id"
action:label = Trc
action:order = 2

There are more than 17 active child tables in relationship.ini
The parent as well as child tables include thousand of entries and the application has more than 2000 users.

The issue occurs when multiple "add new related record" tabs are opened at the same time and we try to enter multiple records at the same time.

I have been able to handle the issue by changing the following else block:

else {
$app =& Dataface_Application::getInstance();
$qt =& Dataface_QueryTool::loadResult($app->_currentTable);
return $qt->loadCurrent();
}

-- to:

else {
$app =& Dataface_Application::getInstance();
return $app->getRecord();
}

at around line 180 Dataface/ShortRelatedRecordForm.php

Thanks!
simb
 
Posts: 4
Joined: Wed Oct 24, 2012 10:07 am

Re: Related Table Erroneous Entries

Postby shannah » Fri Oct 26, 2012 9:47 am

Thanks for posting this. I'm not sure why this fix works, but I'll look into it. I've add a bug report.
http://bugs.weblite.ca/view.php?id=1167
--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: Related Table Erroneous Entries

Postby simb » Fri Oct 26, 2012 10:29 am

Thank you Steve - Always appreciate your support and hardwork!
simb
 
Posts: 4
Joined: Wed Oct 24, 2012 10:07 am


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 24 guests

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