         
         self.encoder.codingPath.append(key)
         defer { self.encoder.codingPath.removeLast() }
-        let keyPath = encoder.codingPath.path
-        try encoder.writeEncodable(value, for: keyPath)
+        try encoder.writeEncodable(value)
     }
     
     func nestedContainer<NestedKey>(keyedBy keyType: NestedKey.Type, forKey key: K) -> KeyedEncodingContainer<NestedKey> where NestedKey : CodingKey {


internal extension PredicateEncoder.Encoder {
    
    func write(_ value: Value, for keyPath: String) {
        values[keyPath] = value
        log?("Did encode \(value.type) value for keyPath \"\(keyPath)\"")
    }
    
    func writeEncodable <T: Encodable> (_ value: T, for keyPath: String) throws {
        
        if let data = value as? Data {
            write(.data(data), for: keyPath)
        } else if let uuid = value as? UUID {
            write(.uuid(uuid), for: keyPath)
        } else if let date = value as? Date {
            write(.date(date), for: keyPath)
        } else {
            // encode using Encodable, container should write directly.
            try value.encode(to: self)

        
        self.encoder.codingPath.append(key)
        defer { self.encoder.codingPath.removeLast() }
        self.encoder.write(value)
    }
}

