Permalink
Browse files

Changing empty string to nil so sql is valid for postgres.

  • Loading branch information...
1 parent a03ea6d commit 442b1a7f4154f206836ecb490786682486982d61 @crystalneth crystalneth committed Mar 13, 2010
Showing with 2 additions and 2 deletions.
  1. +2 −2 app/models/sanction/role.rb
@@ -22,13 +22,13 @@ def valid_role_definition
# See if the intent of this role is captured by another role
def uniqueness_of_intent
conds = []
- conds << ["#{self.class.table_name}.principal_type = ? AND (#{self.class.table_name}.principal_id = ? OR #{self.class.table_name}.principal_id IS NULL)", principal_type, (principal_id || "")]
+ conds << ["#{self.class.table_name}.principal_type = ? AND (#{self.class.table_name}.principal_id = ? OR #{self.class.table_name}.principal_id IS NULL)", principal_type, (principal_id || nil)]
conds << ["#{self.class.table_name}.name = ?", name]
if global?
conds << ["#{self.class.table_name}.global = ?", true]
else
- conds << ["#{self.class.table_name}.permissionable_type = ? AND (#{self.class.table_name}.permissionable_id = ? OR #{self.class.table_name}.permissionable_id IS NULL)", permissionable_type, (permissionable_id || "")]
+ conds << ["#{self.class.table_name}.permissionable_type = ? AND (#{self.class.table_name}.permissionable_id = ? OR #{self.class.table_name}.permissionable_id IS NULL)", permissionable_type, (permissionable_id || nil)]
end
conditions = conds.map {|c| self.class.merge_conditions(c)}.join(" AND ")

0 comments on commit 442b1a7

Please sign in to comment.