<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -189,8 +189,6 @@ module DataMapper
       @links    = normalize_links(@links)
       @includes = normalize_includes(@includes)
 
-      translate_custom_types(@properties, options)
-
       # treat all non-options as conditions
       (options.keys - OPTIONS - OPTIONS.map { |option| option.to_s }).each do |k|
         append_condition(k, options[k])
@@ -218,17 +216,6 @@ module DataMapper
       @conditions = original.conditions.map { |tuple| tuple.dup }
     end
 
-    def translate_custom_types(properties, options)
-      options.each do |key, value|
-        case key
-          when DataMapper::Query::Operator
-            options[key] = properties[key.target].type.dump(value, properties[key.target]) if properties.has_property?(key.target) &amp;&amp; properties[key.target].custom?
-          when Symbol, String
-            options[key] = properties[key].type.dump(value, properties[key]) if properties.has_property?(key) &amp;&amp; properties[key].custom?
-        end
-      end
-    end
-
     # validate the options
     def assert_valid_options(options)
       # validate the reload option and unique option
@@ -440,9 +427,26 @@ module DataMapper
         raise ArgumentError, &quot;Clause #{clause.inspect} does not map to a DataMapper::Property&quot;, caller(2)
       end
 
+      bind_value = dump_custom_value(property, bind_value)
+
       @conditions &lt;&lt; [ operator, property, bind_value ]
     end
 
+    def dump_custom_value(property_or_path, bind_value)
+      case property_or_path
+      when DataMapper::Query::Path
+        dump_custom_value(property_or_path.property, bind_value)
+      when Property
+        if property_or_path.custom?
+          property_or_path.type.dump(bind_value, property_or_path) 
+        else
+          bind_value
+        end
+      else
+        bind_value
+      end
+    end
+
     # TODO: check for other mutually exclusive operator + property
     # combinations.  For example if self's conditions were
     # [ :gt, :amount, 5 ] and the other's condition is [ :lt, :amount, 2 ]</diff>
      <filename>lib/dm-core/query.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>4f84ce896ebb7a064a3a71c2c6f2d2374b9ad4e6</id>
    </parent>
  </parents>
  <author>
    <name>Ben Burkert</name>
    <email>ben@benburkert.com</email>
  </author>
  <url>http://github.com/sam/dm-core/commit/4fbeca8d8b3d7c1207974e91f51229b9a6bf8b20</url>
  <id>4fbeca8d8b3d7c1207974e91f51229b9a6bf8b20</id>
  <committed-date>2008-08-19T11:03:27-07:00</committed-date>
  <authored-date>2008-08-19T11:03:27-07:00</authored-date>
  <message>Fix for #528.  Updates how custom types are dumped in Query.

* If a query involves a custom type, the property value must be dumped via the custom type API.
* Query's with custom types in a Query::Path are handled as a special case.</message>
  <tree>332e2d672af9de72fa9ecd2cbd341d06a95c261e</tree>
  <committer>
    <name>Ben Burkert</name>
    <email>ben@benburkert.com</email>
  </committer>
</commit>
