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

Typename for the Function parameter with %TYPE syntax is not coming up in datums of parsed json #123

Open
priyanshi-yb opened this issue Nov 22, 2024 · 0 comments

Comments

@priyanshi-yb
Copy link

Example

CREATE OR REPLACE FUNCTION get_employee_details(emp_id employees.id%TYPE) 
RETURNS employees.name%TYPE AS $$
DECLARE
    employee_name employees.name%TYPE; -- Matches the type of employees.name column
BEGIN
    SELECT name INTO employee_name FROM employees WHERE id = emp_id;
    RETURN employee_name;
END;
$$ LANGUAGE plpgsql;

parsed json for the above -

 {
        "PLpgSQL_function": {
            "datums": [
                {
                    "PLpgSQL_var": {
                        "refname": "emp_id",
                        "datatype": {
                            "PLpgSQL_type": {
                                "typname": "UNKNOWN"
                            }
                        }
                    }
                },
                {
                    "PLpgSQL_var": {
                        "refname": "found",
                        "datatype": {
                            "PLpgSQL_type": {
                                "typname": "UNKNOWN"
                            }
                        }
                    }
                },
                {
                    "PLpgSQL_var": {
                        "refname": "employee_name",
                        "lineno": 3,
                        "datatype": {
                            "PLpgSQL_type": {
                                "typname": "employees.name%TYPE"
                            }
                        }
                    }
                },
                {
                    "PLpgSQL_row": {
                        "refname": "(unnamed row)",
                        "lineno": 5,
                        "fields": [
                            {
                                "name": "employee_name",
                                "varno": 2
                            }
                        ]
                    }
                }
            ],
            "action": {
                ....
            }
        }
    },

for parameter emp_id employees.id%TYPE the typename is coming up as "PLpgSQL_type": { "typname": "UNKNOWN" }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant