I'm developing Merb application using DM 0.9.6 gems. I'm observing  
that whatever query I use, IdentityMap is not working and the same SQL  
queries are repeated all over the time.

Even simple <model>.get(<id>) leads to repetitive SQL queries:

Person.get('0389acd2-c151-4e00-9f29-4143685342f5')
  ~ SELECT "id" FROM "people" WHERE ("id" = '0389acd2- 
c151-4e00-9f29-4143685342f5') ORDER BY "id" LIMIT 1
     #==>#<Person id="0389acd2-c151-4e00-9f29-4143685342f5">

Person.get('0389acd2-c151-4e00-9f29-4143685342f5')
  ~ SELECT "id" FROM "people" WHERE ("id" = '0389acd2- 
c151-4e00-9f29-4143685342f5') ORDER BY "id" LIMIT 1
     #==>#<Person id="0389acd2-c151-4e00-9f29-4143685342f5">

This is what I get after running any sort of queries:

Person.repository.identity_map(Person)
     #==>#<DataMapper::IdentityMap:0x2772ef8 @second_level_cache=nil,  
@cache={}>


Could anybody tell me whether this is a bug, a feature, or  
misconfiguration in my environment? I really hope to have IdentityMap  
running as intended with the ability to specify second level cache  
such as memcached buckets.



Definitions:

class Person
   include DataMapper::Resource
   property :id, DataMapper::Types::UUID, :key => true, :nullable =>  
false
end

require 'uuidtools'

module DataMapper
   module Types
     class UUID < DataMapper::Type
       primitive String
       # DON'T USE unique(true)! This causes stupid queries like:
       # ~ SELECT "id" FROM "people" WHERE ("id" = '804c9b...') ORDER  
BY "id" LIMIT 1
       size 36
       default lambda { ::UUID.random_create.to_s }

       def self.load(value, property)
         value.to_s.downcase if value
       end

       def self.dump(value, property)
         return nil unless value
         value.to_s.downcase
       end

       def self.typecast(value, property)
         value ? load(value.to_s, property) : nil
       end
     end
   end
end


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/datamapper?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to