typecast extracted keys #8

merged 1 commit into from Aug 11, 2011


None yet
3 participants

ghost commented Aug 2, 2011

The extract_keys_for_nested_attributes method fails to typecast the keys extracted from the attributes hash. The attributes hash provided by Rack-based applications including Rails has keys and values that are all strings. In Rack-based environments, updating a nested one-to-one association will (attempt to) create a new resource rather than update an existing one. This bug was not caught by the existing specs since native keys were supplied in the hash.

This changeset updates extract_keys_for_nested_attributes in DataMapper::NestedAttributes::Relationship and its associated specs. Comment line 35 to watch the new specs fail.

class ::Address
include DataMapper::Resource
property :id, Serial
- property :profile_id, Integer, :required => true, :unique => true, :unique_index => true, :min => 0

snusnu Aug 11, 2011


Any special reason you've removed this line? It doesn't seem to affect the specs (old+new), so i'm just wondering. One could argue that in the real world, that uniqueness restriction wouldn't make sense anyway. I don't remember if this was put in for a reason, at some point ...

snusnu added a commit that referenced this pull request Aug 11, 2011

Merge pull request #8 from adelyte/master
typecast extracted keys

@snusnu snusnu merged commit 0a42e3f into snusnu:master Aug 11, 2011


snusnu commented Aug 11, 2011


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment