Default value for Hstore column #11520

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

Projects

None yet

2 participants

@vgeorge
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
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