Splitting this out from #3978 since @mdietze suggested it as a separate issue.
Right now get_trait_data_pft() requires the caller to pass a non-empty trait_names. There's a useful case where you just want "all priors for this PFT" — you shouldn't need to know the trait list up front, which today means doing an extra DB query before calling.
The fix is small: let trait_names default to NULL. When it's NULL, pass NULL (or empty trstr) to query.priors so it returns all priors for the pft_id, and then derive trait_names from rownames(prior_distns) for the trait query that follows.
Fully backward compatible — anyone passing trait_names explicitly today sees no change.
One thing I want to check before the PR: query.priors needs to handle trstr = NULL (or empty) and return all priors. If it doesn't already, it's a small tweak to drop the WHERE name IN (...) clause when there's nothing to filter on. Happy to include that in the same PR if needed.
Will pick this up after #3978 lands.
Splitting this out from #3978 since @mdietze suggested it as a separate issue.
Right now
get_trait_data_pft()requires the caller to pass a non-emptytrait_names. There's a useful case where you just want "all priors for this PFT" — you shouldn't need to know the trait list up front, which today means doing an extra DB query before calling.The fix is small: let
trait_namesdefault toNULL. When it's NULL, pass NULL (or emptytrstr) toquery.priorsso it returns all priors for thepft_id, and then derivetrait_namesfromrownames(prior_distns)for the trait query that follows.Fully backward compatible — anyone passing
trait_namesexplicitly today sees no change.One thing I want to check before the PR:
query.priorsneeds to handletrstr = NULL(or empty) and return all priors. If it doesn't already, it's a small tweak to drop theWHERE name IN (...)clause when there's nothing to filter on. Happy to include that in the same PR if needed.Will pick this up after #3978 lands.