vubiostat / redcapAPI

R interface to REDCap (http://www.project-redcap.org/)
15 stars 26 forks source link

Warning Displayed Multiple Times for Nonexistent Secondary Unique Field #376

Closed jubilee2 closed 4 weeks ago

jubilee2 commented 4 weeks ago

When using the exportRecordsTyped function, I encounter the warning

Warning: Project information specifies a secondary unique field that does not exist. 

This warning is displayed twice, which seems unnecessary as it appears to be a database-level warning rather than a record-level warning. The repetition of this warning for the size of the row set does not seem logical.

Screenshot 2024-05-15 at 5 02 40 PM
spgarbet commented 4 weeks ago

It has nothing to do with the number of rows. The logic asks for that data twice in processing the export.

> nrow(exportRecordsTyped(rcon))
[1] 41
Warning messages:
1: In getProjectIdFields(rcon) :
  Project information specifies a secondary unique field that does not exist.
2: In getProjectIdFields(rcon) :
  Project information specifies a secondary unique field that does not exist.
spgarbet commented 4 weeks ago

The warning check could be moved up to when the metadata is pulled and it would happen once. This would cause a dependency on project information and caching would have to be revisited between these two. The present logic here has the check at the point of computation of the key, which is a cohesive place to put it. The best way to get rid of the message is for the metadata of the project to be corrected. There have been several surprises for users when it was set incorrectly. Having it a bit noisy for misconfiguration while keeping the code simpler seems like a good trade.