Specifying PK On Query with a Join

LabKey Support Forum (Inactive)
Specifying PK On Query with a Join trent  2011-08-24 17:02
Status: Closed
 
Anyone know how do I specify a PK when my query has a join (or if its possible)?

Im generally use the LABKEY.DataRegion object to get the selected items, but when there's a join, no column is marked as a PK, so just returns an empty set of strings as the checked items.

LABKEY.DataRegions[wp.dataRegionName].getChecked()

https://www.labkey.org/download/schema-docs/xml-schemas/schemas/tableInfo_xsd/schema-summary.html :

<xs:element minOccurs="0" name="pkColumnName" type="xs:string">
<xs:annotation>
<xs:documentation>
A comma-separated ordered list of the column name values that comprise the primary
key of the table. Used for list export/import.
</xs:documentation>
</xs:annotation>
</xs:element>

https://www.labkey.org/download/schema-docs/xml-schemas/schemas/tableInfo_xsd/elements/pkColumnName.html

XML Representation Summary
<dat:pkColumnName
       
Content:
{ xs:string }
</dat:pkColumnName>

So I tried adding to my metadata xml:

<ns:tables xmlns:ns="http://labkey.org/data/xml">
  <ns:table tableName="test1" tableDbType="NOT_IN_DB">
    <ns:columns>
      <ns:column columnName="specimen_id">
        <ns:description>blabla</ns:description>
      </ns:column>
    </ns:columns>
    <ns:pkColumnName>
    list_id
    </ns:pkColumnName>
  </ns:table>
</ns:tables>

Is my syntax fail? (It doesn't mark that col as PK)
 
 
jeckels responded:  2011-08-24 17:06
Hi Trent,

In your metadata XML, try adding a <ns:isKeyField>true</ns:isKeyField> element to the column itself. I've used that with success with custom queries before.

Thanks,
Josh
 
trent responded:  2011-08-24 17:27
Awesome, That did the trick!

Thanks!

 
trent responded:  2012-04-22 22:48
Scrap this. I now realise you can (obviously) only define metadata for columns directly in the select definition. Sorry for the bump. Is there a trick when there is no join? i.e. How do I reference columns in linked tables - can't seem to get this to work.