Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

removed symbolized representation of primary keys. main reason: in ac…

…tive record, primary key is always a string. this breaks primary key usage in some gems like delayed job
  • Loading branch information...
commit bbf3f0e77046fa68792c44d370659e4939d6435d 1 parent de6d48c
Tiago Cardoso authored
View
1  .rvmrc
@@ -0,0 +1 @@
+rvm use ruby-1.9.3@rc-logic
View
2  lib/composite_primary_keys/base.rb
@@ -27,7 +27,7 @@ def primary_keys=(keys)
return
end
- @primary_keys = keys.map { |k| k.to_sym }.to_composite_keys
+ @primary_keys = keys.map { |k| k.to_s }.to_composite_keys
class_eval <<-EOV
extend CompositeClassMethods
View
4 lib/composite_primary_keys/dirty.rb
@@ -5,12 +5,12 @@ def can_change_primary_key?
end
def primary_key_changed?
- !!changed.detect { |key| ids_hash.keys.include?(key.to_sym) }
+ !!changed.detect { |key| ids_hash.keys.include?(key.to_s) }
end
def primary_key_was
ids_hash.keys.inject(Hash.new) do |result, attribute_name|
- result[attribute_name.to_sym] = attribute_was(attribute_name.to_s)
+ result[attribute_name] = attribute_was(attribute_name.to_s)
result
end
end
View
4 test/test_ids.rb
@@ -78,7 +78,7 @@ def test_primary_keys
testing_with do
if composite?
assert_not_nil @klass.primary_keys
- assert_equal @primary_keys.map {|key| key.to_sym}, @klass.primary_keys
+ assert_equal @primary_keys.map {|key| key.to_s}, @klass.primary_keys
assert_equal @klass.primary_keys, @klass.primary_key
assert_kind_of(CompositePrimaryKeys::CompositeKeys, @klass.primary_keys)
assert_equal @primary_keys.map {|key| key.to_sym}.join(','), @klass.primary_key.to_s
@@ -91,7 +91,7 @@ def test_primary_keys
end
def test_inherited_primary_keys
- assert_equal([:reference_type_id, :reference_code], ChildCpkTest.primary_keys)
+ assert_equal(["reference_type_id", "reference_code"], ChildCpkTest.primary_keys)
end
def test_inherited_ids
View
6 test/test_update.rb
@@ -41,13 +41,13 @@ def test_update_primary_key
obj.reference_type_id = 2
obj.reference_code = 3
assert(obj.primary_key_changed?)
- assert_equal({:reference_type_id => 1, :reference_code => 1}, obj.primary_key_was)
- assert_equal({:reference_type_id => 2, :reference_code => 3}, obj.ids_hash)
+ assert_equal({"reference_type_id" => 1, "reference_code" => 1}, obj.primary_key_was)
+ assert_equal({"reference_type_id" => 2, "reference_code" => 3}, obj.ids_hash)
assert(obj.save)
assert(obj.reload)
assert_equal(2, obj.reference_type_id)
assert_equal(3, obj.reference_code)
- assert_equal({:reference_type_id => 2, :reference_code => 3}, obj.ids_hash)
+ assert_equal({"reference_type_id" => 2, "reference_code" => 3}, obj.ids_hash)
assert_equal([2, 3], obj.id)
end
Please sign in to comment.
Something went wrong with that request. Please try again.