Lookup widget on view with compound primary key

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

Lookup widget on view with compound primary key

Postby ADobkin » Sun Apr 15, 2012 7:38 am

I have encountered an interesting situation with one of my tables. I have a view which requires a compound primary key. It is a table based on a calendar with repeating events. The view itself works fine in Xataface.

In another table, I am using a lookup widget to pick dates from the view. They show up correctly in the lookup widget list, but they were not being saved to the database. I was using an INT field to save the ID, but they were all saved as 0, so I changed it to VARCHAR to see if it would display a text value.

As it turns out, this is what is being stored in the database for this field:

tablename_view?keyid1=XX&keyid2=XX (where XX is replaced by the actual ID numbers)

Is this normal? I wasn't sure quite what to expect here, but if I leave this field set to VARCHAR, it does work properly now.
ADobkin
 
Posts: 195
Joined: Mon Oct 22, 2007 7:31 pm
Location: Atlanta, GA, USA

Re: Lookup widget on view with compound primary key

Postby shannah » Sun Apr 15, 2012 10:11 am

Yes. This is not documented but is normal. The lookup widget will return the value of the primary key for the id if there is a single column primary key. If there is a multi-column primary key, it instead returns the Xataface unique record id. Xataface record Ids are in the format
tablename?key1=val1&key2=val2

The Xataface API has a number of functions designed to deal with this type of ID, and it's relatively easy to parse if you need a particular key value.

-Steve
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: Lookup widget on view with compound primary key

Postby ADobkin » Sun Apr 15, 2012 10:21 am

Perfect, thanks! I will add a pointer to this post in the wiki.
ADobkin
 
Posts: 195
Joined: Mon Oct 22, 2007 7:31 pm
Location: Atlanta, GA, USA


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