Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve function context usda.* on cli analyze, with get_nutrients_by_food_ids() #37

Open
gamesguru opened this issue Jun 26, 2020 · 0 comments
Assignees

Comments

@gamesguru
Copy link
Member

Either try to find a way to specify a context in the function generation, or instantiate separate connections foreach schema, or explicitly preface the non-primary schema functions with their schema.

[psql]   SELECT * FROM usda.get_nutrients_by_food_ids(ARRAY[1002]);
[psql]   ERROR:  relation "food_des" does not exist
LINE 9:     food_des des
            ^
QUERY:  
  SELECT
    des.id,
    des.fdgrp_id,
    long_desc,
    manufacturer,
    json_agg(json_build_object('nutr_id', val.nutr_id, 'nutr_desc', nutr_desc, 'tagname', tagname, 'nutr_val', nutr_val, 'units', units)) AS nutrients
  FROM
    food_des des
  LEFT JOIN nut_data val ON val.food_id = des.id
  LEFT JOIN nutr_def def ON def.id = val.nutr_id
WHERE
  des.id = ANY (food_id_in)
GROUP BY
  des.id,
  long_desc

CONTEXT:  SQL function "get_nutrients_by_food_ids" during startup
@gamesguru gamesguru self-assigned this Jun 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant