Created
June 28, 2010 02:11
-
-
Save rtirrell/455358 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ERROR ONE | |
>> c = Cor.get(1060, :cid, :spearman) | |
~ (0.002499) SELECT `id`, `type`, `meth`, `cor`, `pval`, `pval_adj`, `perm_pval`, `len` FROM `cors` WHERE (`type` = 1 AND `meth` = 2 AND `id` = '1060') ORDER BY `id`, `type`, `meth` LIMIT 1 | |
=> #<Cor @id="1060" @type=:cid @cor=0.0115675 @pval=0.315327 @pval_adj=nil @perm_pval=0.311 @meth=:spearman @len=7537> | |
>> c.update :pval_adj => 0.001 | |
DataMapper::ImmutableError: Immutable resource cannot be modified | |
from /Library/Ruby/Gems/1.8/gems/dm-core-1.0.0/lib/dm-core/resource/state/immutable.rb:16:in `set' | |
from /Library/Ruby/Gems/1.8/gems/dm-core-1.0.0/lib/dm-core/model/property.rb:269:in `pval_adj=' | |
from /Library/Ruby/Gems/1.8/gems/dm-core-1.0.0/lib/dm-core/resource.rb:345:in `__send__' | |
from /Library/Ruby/Gems/1.8/gems/dm-core-1.0.0/lib/dm-core/resource.rb:345:in `attributes=' | |
from /Library/Ruby/Gems/1.8/gems/dm-core-1.0.0/lib/dm-core/resource.rb:341:in `each' | |
from /Library/Ruby/Gems/1.8/gems/dm-core-1.0.0/lib/dm-core/resource.rb:341:in `attributes=' | |
from /Library/Ruby/Gems/1.8/gems/dm-core-1.0.0/lib/dm-core/resource.rb:390:in `update' | |
from (irb):29 | |
>> | |
# ERROR TWO | |
>> cor = Cor.first | |
~ (0.003168) SELECT `id`, `type`, `meth`, `cor`, `pval`, `pval_adj`, `perm_pval`, `len` FROM `cors` ORDER BY `id`, `type`, `meth` LIMIT 1 | |
=> #<Cor @id="1059" @type=:cid @cor=-0.0339791 @pval=1.82219e-05 @pval_adj=nil @perm_pval=0.001 @meth=:pearson @len=15901> | |
>> cor.update :pval_adj => 0.001 | |
DataMapper::ImmutableError: Immutable resource cannot be modified | |
from /Library/Ruby/Gems/1.8/gems/dm-core-1.0.0/lib/dm-core/resource/state/immutable.rb:16:in `set' | |
from /Library/Ruby/Gems/1.8/gems/dm-core-1.0.0/lib/dm-core/model/property.rb:269:in `pval_adj=' | |
from /Library/Ruby/Gems/1.8/gems/dm-core-1.0.0/lib/dm-core/resource.rb:345:in `__send__' | |
from /Library/Ruby/Gems/1.8/gems/dm-core-1.0.0/lib/dm-core/resource.rb:345:in `attributes=' | |
from /Library/Ruby/Gems/1.8/gems/dm-core-1.0.0/lib/dm-core/resource.rb:341:in `each' | |
from /Library/Ruby/Gems/1.8/gems/dm-core-1.0.0/lib/dm-core/resource.rb:341:in `attributes=' | |
from /Library/Ruby/Gems/1.8/gems/dm-core-1.0.0/lib/dm-core/resource.rb:390:in `update' | |
from (irb):24 | |
>> | |
# MODEL | |
require "dm-core" | |
require "dm-types" | |
class Cor | |
include DataMapper::Resource | |
def self.default_repository_name | |
:default | |
end | |
property :id, String, :key => true | |
property :type, Enum[:cid, :cui], :key => true | |
property :cor, Float | |
property :pval, Float | |
property :pval_adj, Float | |
property :perm_pval, Float | |
property :meth, Enum[:pearson, :spearman], :key => true | |
property :len, Integer | |
def dz_name | |
if type == :cid | |
SubsetComparison.get(id.to_i).dz_name | |
else | |
Disease.get(id).name | |
end | |
end | |
end | |
# WORKS | |
repository(:default).adapter.execute("UPDATE cors SET pval_adj = 0.001 WHERE id = 1060 AND type = 1 AND meth = 1;") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment