madeintandem/hstore_accessor

Adding to hstore Array does not work

resistorsoftware opened this issue · 2 comments

Hi,

In my model Order I have an hstore setup as:

hstore_accessor :refund, refunds: :array

I can set an array with no trouble:

order.refunds = [123456]
=> [123456]

But I cannot push new values to an array

order.refunds.push 44332211
=> [123456,44332211]
order.refunds
=> [123456]

Same with the << syntax

Am I missing something basic here? If the class of the column is Array, I think .push and << should work... otherwise this is not too terribly useful? I would need to save the old array to some temp variable, push to that, and then set the new array?

Anyone else see this behaviour with arrays?

Unfortunately I think this is somewhat unavoidable and works the same way
array columns (not hstore backed, but actually Postgres array columns) work
with ActiveRecord.

Thanks,
//JC Grubbs | DevMynd
(717) 347-8227
http://devmynd.com

On Mon, Apr 14, 2014 at 2:41 PM, David Lazar notifications@github.comwrote:

Hi,

In my model Order I have an hstore setup as:

hstore_accessor :refund, refunds: :array

I can set an array with no trouble:

order.refunds = [123456]
=> [123456]

But I cannot push new values to an array

order.refunds.push 44332211
=> [123456,44332211]
order.refunds
=> [123456]

Same with the << syntax

Am I missing something basic here? If the class of the column is Array, I
think .push and << should work... otherwise this is not too terribly
useful? I would need to save the old array to some temp variable, push to
that, and then set the new array?

Anyone else see this behaviour with arrays?


Reply to this email directly or view it on GitHubhttps://github.com//issues/22
.

Ok.. no biggy.. through me for a bit, but after going through the source code, and seeing no implementation of Enumerable, I get it... I will code accordingly... thanks!