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

Default value for Hstore column #11520

Closed
vgeorge opened this issue Jul 20, 2013 · 1 comment
Closed

Default value for Hstore column #11520

vgeorge opened this issue Jul 20, 2013 · 1 comment

Comments

@vgeorge
Copy link

vgeorge commented Jul 20, 2013

Is is possible to set a default value for the new native Hstore column?

I'll quote @jjb, who explains the problem at issue 22 of activerecord-postgres-hstore gem:

Here's a problem I have, which might be (very?) common for users of this gem: I have a model Foo with an hstore column metadata. It's possible that it has no metadata at all, or many key/values. Wherever I access the metadata, I have to do ye olde @foo.metadata && @foo.metadata['my_key'] because @foo.metadata might be nil.

I would rather that in the case of a NULL metadata column, @foo.metadata returned {}. In my use case, metadata being nil has no semantic purpose.

Seems like it was solved for the gem in this commit.

@steveklabnik
Copy link
Member

We only keep Issues for bug reports, please ask questions about how to use Rails on Stack Overflow, thanks.

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