Security News
PyPI’s New Archival Feature Closes a Major Security Gap
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
Store nested hashes and other types in ActiveRecord hstores
Postgres hstores offer a number of benefits, but they don't natively support multi-level data. Nested Hstore adds this support to ActiveRecord, letting you treat an hstore like a NoSQL-like document.
Hstore functions are still supported at the root level.
It also lets you store data types other than hashes in an hstore. All of the following values will be returned verbatim:
class User < ActiveRecord::Base
serialize :my_property, ActiveRecord::Coders::NestedHstore
end
# Nested hash
user.my_property = {
'name' => 'Jane Doe',
'comment_ids' => [34, 67, 82],
'location' => {
'id' => 15,
'city' => 'San Francisco',
'state' => 'CA'
}
}
# Array
user.my_property = [34, 67, 82]
# Array of nested hashes
user.my_property = [
{
'id' => 15,
'username' => 'janedoe'
},
{
'id' => 16,
'username' => 'johndoe'
}
]
# Boolean
user.my_property = true
# Integer
user.my_property = 43
# Float
user.my_property = 43.1
# String
user.my_property = 'janedoe'
If you're using ActiveRecord 2.x or 3.x, set up activerecord-postgres-hstore if you haven't already. This isn't necessary for ActiveRecord 4.x.
Include it in your Gemfile:
gem 'nested-hstore'
Serialize each property using ActiveRecord::Coders::NestedHstore
:
class User < ActiveRecord::Base
serialize :my_property, ActiveRecord::Coders::NestedHstore
end
Nested Hstore is tested against ActiveRecord 3 and 4. If you'd like to submit a PR, please be sure to use Appraisal to test your changes in both contexts:
appraisal rspec
Nested Hstore is released under the MIT License. Please see the MIT-LICENSE file for details.
FAQs
Unknown package
We found that nested-hstore demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
Research
Security News
Malicious npm package postcss-optimizer delivers BeaverTail malware, targeting developer systems; similarities to past campaigns suggest a North Korean connection.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.