Closed tpitale closed 9 years ago
Subsequent calls to exactly the same method work. Always fails the first time.
This may be a dm-core issue, and only happens to manifest through dm-types because of the DirtyMinder module misdirection.
This appears to be related to https://github.com/datamapper/dm-types/pull/71. Closing.
Loading a collection at all, for the first time (as empty?
evidently does in dm) where one of the properties is Json
, Hash
, or Array
(the classes extended by hooks for dirtiness tracking) leads to this error. No other collection loading fails in this way. Pretty sure that makes it a dm-types issue.
This is fixed by PR #50. But, despite it saying in the release from github that v1.2.2 https://github.com/datamapper/dm-types/compare/v1.2.2...master has that PR included, looking at the code for the gem release 1.2.2 it does not have the code from PR #50.
This issue has made me regret use datamapper at all :/
same here. that's bad.
Well, same issue. Had to fork v1.2.2 and cherry pick the 3 commits from #50.
Now, I just have to add this to my Gemfile
:
gem 'dm-types',
:git => 'git://github.com/julienma/dm-types.git',
:branch => 'gem-v1.2.2-with-frozen-nilclass-fix'
kinda looks like this still isn't fixed, is this ever going to be fixed?
2016-06-30T14:17:40.172+0000 ERROR pwnscan#9456: Generic Error: can't
modify frozen NilClass
["/var/lib/gems/2.3.0/gems/dm-types-1.2.2/lib/dm-types/support/dirty_minder.rb:144:in
`track'",
"/var/lib/gems/2.3.0/gems/dm-types-1.2.2/lib/dm-types/support/dirty_minder.rb:161:in
`hook_value'",
"/var/lib/gems/2.3.0/gems/dm-types-1.2.2/lib/dm-types/support/dirty_minder.rb:151:in
`set!'",
"/var/lib/gems/2.3.0/gems/dm-core-1.2.1/lib/dm-core/resource.rb:880:in
`block in eager_load'",
"/var/lib/gems/2.3.0/gems/dm-core-1.2.1/lib/dm-core/resource.rb:880:in
`each'",
"/var/lib/gems/2.3.0/gems/dm-core-1.2.1/lib/dm-core/resource.rb:880:in
`eager_load'",
"/var/lib/gems/2.3.0/gems/dm-core-1.2.1/lib/dm-core/resource.rb:865:in
`lazy_load'",
"/var/lib/gems/2.3.0/gems/dm-core-1.2.1/lib/dm-core/property.rb:664:in
`lazy_load'",
"/var/lib/gems/2.3.0/gems/dm-core-1.2.1/lib/dm-core/resource/persistence_state/persisted.rb:23:in
`lazy_load'",
"/var/lib/gems/2.3.0/gems/dm-core-1.2.1/lib/dm-core/resource/persistence_state/persisted.rb:8:in
`get'",
"/var/lib/gems/2.3.0/gems/dm-core-1.2.1/lib/dm-core/model/property.rb:209:in
`attributes_meta'",
"/opt/pwnix/pwnscan/lib/pwnscan/helpers/host_update_helper.rb:21:in
`initialize'",
"/opt/pwnix/pwnscan/lib/pwnscan/models/network_host.rb:252:in `new'",
"/opt/pwnix/pwnscan/lib/pwnscan/models/network_host.rb:252:in
`update_from_parsed_hash'",
"/opt/pwnix/pwnscan/lib/pwnscan/models/network_host.rb:265:in
`mark_offline'",
"/opt/pwnix/pwnscan/lib/pwnscan/models/network_host.rb:97:in `block in
deduplicate'",
"/var/lib/gems/2.3.0/gems/dm-core-1.2.1/lib/dm-core/collection.rb:508:in
`block in each'",
"/var/lib/gems/2.3.0/gems/dm-core-1.2.1/lib/dm-core/support/lazy_array.rb:411:in
`block in each'",
"/var/lib/gems/2.3.0/gems/dm-core-1.2.1/lib/dm-core/support/lazy_array.rb:411:in
`each'",
"/var/lib/gems/2.3.0/gems/dm-core-1.2.1/lib/dm-core/support/lazy_array.rb:411:in
`each'",
"/var/lib/gems/2.3.0/gems/dm-core-1.2.1/lib/dm-core/collection.rb:505:in
DM is mostly unmaintained. So, no, probably not getting fixed.
Ran into this as well, accelerated a project's move off datamapper.
This can be avoided by turning off lazy loading for the property.
property :some_json, Json, lazy: false
Obviously, you lose the benefits of lazy loading.
Calling
empty?
on anhas n
association. Ruby 2.2.0, worked previous versions of ruby.