Skip to content
This repository was archived by the owner on Dec 23, 2025. It is now read-only.
This repository was archived by the owner on Dec 23, 2025. It is now read-only.

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

Description

@gamesguru

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions