Permalink
Browse files

Fix bug where chaining breaks Child.has(:token).over(@klass) would er…

…ror (nil.[])

  There seems to be a larger bug with our Join sniffing. Removing it for now, tests still pass?
  • Loading branch information...
1 parent 3212858 commit 47421dfef9e0293c1d130699d5bba0c85fe76770 @pjleonhardt pjleonhardt committed Jul 27, 2010
Showing with 4 additions and 4 deletions.
  1. +4 −4 lib/sanction/principal/base.rb
@@ -37,19 +37,19 @@ def self.is_a_principal?
unless already_joined
returned_scope.merge( {:joins => "INNER JOIN #{Sanction::Role.table_name} AS #{ROLE_ALIAS} ON
(#{ROLE_ALIAS}.principal_id = #{base.table_name}.#{base.primary_key.to_s} OR #{ROLE_ALIAS}.principal_id IS NULL)
- AND #{ROLE_ALIAS}.principal_type = '#{base.name.to_s}'"} )
+ AND #{ROLE_ALIAS}.principal_type = '#{base.name}'"} )
end
}
base.named_scope :as_principal, lambda {|klass_instance|
already_joined = Sanction::Extensions::Joined.already? base, ROLE_ALIAS
returned_scope = {:conditions => ["#{klass_instance.class.table_name}.#{klass_instance.class.primary_key.to_s} = ?", klass_instance.id], :select => "DISTINCT #{klass_instance.class.table_name.to_s}.*"}
- unless already_joined
+ # unless already_joined
returned_scope.merge({:joins => "INNER JOIN #{Sanction::Role.table_name} AS #{ROLE_ALIAS} ON
(#{ROLE_ALIAS}.principal_id = '#{klass_instance.id}' OR #{ROLE_ALIAS}.principal_id IS NULL) AND
- #{ROLE_ALIAS}.principal_type = '#{klass_instance.class.name.to_s}'"})
- end
+ #{ROLE_ALIAS}.principal_type = '#{klass_instance.class.name}'"})
+ # end
}
end
end

0 comments on commit 47421df

Please sign in to comment.