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

Support for h_store #18

Open
ghivert opened this issue May 4, 2024 · 3 comments
Open

Support for h_store #18

ghivert opened this issue May 4, 2024 · 3 comments

Comments

@ghivert
Copy link
Sponsor Contributor

ghivert commented May 4, 2024

Postgres supports the h_store type, to manage a hash map directly in PG columns.
While it's probably easier to use jsonb nowadays, it could be useful to add support for older DB.

After diving in pg_types, used internally by pgo, I figured out that pushing a native gleam Dict is enough. Right now, using the ugly dynamic trick (from |> unsafe_coerce) is working, but we could think to add a function like hstore: fn (Dict(String, a)) -> Value in the future.

I'm not sure we should add such a function to the package, but I think it's useful enough to keep this info somewhere, at least to let people interested to know there's a solution to their problem, and wait before someone really needs it before implementing a solution? To make sure we have a correct API.

@lpil
Copy link
Owner

lpil commented May 4, 2024

I was under the impression that jsonb is superior to hstore in every way. Do you have a use case?

@ghivert
Copy link
Sponsor Contributor Author

ghivert commented May 4, 2024

I'm using jsonb personally, so no. Outside of legacy support for old versions of postgres, I see no usage. I just wanted to keep some trace that pushing a Dict in pgo is working with pg_types.

@lpil
Copy link
Owner

lpil commented May 4, 2024

Fab, thanks. Let's hold off until we have a use case

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

2 participants