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

unknown PostgreSQL type: json #459

Closed
farwydi opened this issue Apr 21, 2020 · 2 comments · Fixed by #461
Closed

unknown PostgreSQL type: json #459

farwydi opened this issue Apr 21, 2020 · 2 comments · Fixed by #461
Labels
📚 postgresql bug Something isn't working

Comments

@farwydi
Copy link

farwydi commented Apr 21, 2020

PostgreSQL vers 10

Shema

CREATE TABLE meta_point_params
(
    id         SERIAL       NOT NULL
        CONSTRAINT meta_point_params_pk
            PRIMARY KEY,
    point_id   INTEGER      NOT NULL
        CONSTRAINT meta_point_params_points_id_fk
            REFERENCES points
            ON DELETE CASCADE,
    param_name VARCHAR(208) NOT NULL,
    value      JSON         NOT NULL
);

Query:

-- name: PreFetchPointParamsByPointIds :many
SELECT *
FROM meta_point_params mpp
         INNER JOIN points p ON mpp.point_id = p.id
WHERE p.id = $1;
@farwydi
Copy link
Author

farwydi commented Apr 21, 2020

Should be json.RawMessage or []byte

@farwydi
Copy link
Author

farwydi commented Apr 21, 2020

Simple solution in the config

overrides:
  - go_type: "encoding/json.RawMessage"
    db_type: "json"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📚 postgresql bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants