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

How to read postgres hstore column? #25

Closed
thomasnal opened this issue Aug 29, 2017 · 4 comments
Closed

How to read postgres hstore column? #25

thomasnal opened this issue Aug 29, 2017 · 4 comments
Assignees

Comments

@thomasnal
Copy link
Contributor

As a user, I would like Jennifer to deserialize content of HStore column from Postgres database.

Column verification_score is expected to be a (String | Nil) but got Slice(UInt8). (Jennifer::DataTypeMismatch)
           Column           |            Type             |                     Modifiers
----------------------------+-----------------------------+---------------------------------------------------- 
 verification_score         | hstore                      |

The idea behind using crystal String was that I can then parse the value into Hash. Is there a way that Jennifer can automate it? How would I do it by myself Slice(UInt8) does not sound right for the value such as,

                                                                                                                      verification_score
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
"email"=>"5", "total"=>"35", "quotes"=>"5", "selfies"=>"0", "twitter"=>"5", "facebook"=>"5", "linkedin"=>"5", "instagram"=>"0", "strengths"=>"{\"facebook\"=>1, \"instagram\"=>0, \"linkedin\"=>1, \"twitter\"=>1}", "audio_tracks"=>"5", "phone_number"=>"5"
@z64
Copy link
Contributor

z64 commented Aug 29, 2017

I believe the issue is that crystal-pg does not support hstore.

https://github.com/will/crystal-pg#supported-datatypes

@imdrasil
Copy link
Owner

Yep - officially it is not supported for now. But I already have several things which are not supported 😎 . Will try to find documentation how it stores hstore and maybe will add some workaround to mapping it to string. But I don't promise ).

@thomasnal
Copy link
Contributor Author

:) Thanks. I commented these fields out. I don't use them as they have been converted to table and columns. I am good here.

crystal-pg is preparing hstore read though will/crystal-pg#89

I'm good to close this issue.

@imdrasil
Copy link
Owner

So for now I close this issue. When Hstore will be added to official postgres driver - will update allowed data types.

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

3 participants