Error when using Labkey.Query.insertRows with a null value for server managed key.

LabKey Support Forum (Inactive)
Error when using Labkey.Query.insertRows with a null value for server managed key. Anthony Corbett  2013-01-24 08:55
Status: Closed
 
As part of upgrading our Labkey server from 12.2 to 12.3, I was doing some testing on my javascript code that used LABKEY.Query.insertRow() and I'm seeing behavior differences for a single use case.


In some of our clinical studies there are datasets which have multiple rows per ParticipantVisit and therefore need a third composite key. In the instances where we don't have a pre-defined number of rows (as in using a list for a lookup to restrict the value of the composite keys) or care about using a date along with the ParticipantId and SeqNum we tend to use a Labkey managed auto-incrementing int column called 'id'.


When I execute the following insert command, where the managed key is sent with a null value, I receive an error response from the server:

LABKEY.Query.insertRows({
  schemaName: 'study',
  queryName: 'Current Medications',
  rows: [
     { id: null, frequency: '2xdaily', ParticipantId: 'AP002', SequenceNum: 99, dose: '85mg', medication: 'asprin' }
  ]
});


Error: Could not convert '2xdaily' for field SequenceNum, should be of type BigDecimal


I'm not sure why it is trying to use a completely different field value for SequenceNum? This exact code worked on 12.2.

I did further testing on 12.3 and if I leave out the managed key and null value from the row's JSON it inserts fine.

Also, I tried going to the grid view then to insert new to try the Labkey generated form to insert new data. And this works fine.

I think the Labkey managed key should be ignored during an insertRows() operation (maybe ignored if null and an error if it is populated?); certainly it should NOT be mixing up the SequenceNum value...
 
 
Anthony Corbett responded:  2013-03-20 09:35
Can anyone verify this issue? Thanks.
 
Nick Kerr responded:  2013-03-20 11:36
Hi Anthony,

I'm taking a look at this. Thanks for reporting this issue and I'll post an update when I have more information.

Thanks,
Nick
 
Nick Kerr responded:  2013-03-20 17:14
Hi Anthony,

I've opened an issue after some investigation and we'll look into getting this resolved.

https://www.labkey.org/issues/home/Developer/issues/details.view?issueId=17433

Thanks,
Nick
 
Nick Kerr responded:  2013-03-21 14:47
Hi Anthony,

We've fixed this issue on our development branch so this issue should be fixed in the 13.1 release of LabKey.

To get around this for the time being, in the specific case that you linked try not including the third key ('id' in your case) when it is null.

Thanks,
Nick