<!-- 
RSS generated by JIRA (4.4#649-r158309) at Thu May 23 10:25:30 CDT 2013

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary add field=key&field=summary to the URL of your request.
For example:
http://dev.clojure.org/jira/si/jira.issueviews:issue-xml/CLJ-1011/CLJ-1011.xml?field=key&field=summary
-->
<rss version="0.92" >
<channel>
    <title>Clojure JIRA</title>
    <link>http://dev.clojure.org/jira</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>4.4</version>
        <build-number>649</build-number>
        <build-date>25-07-2011</build-date>
    </build-info>

<item>
            <title>[CLJ-1011] clojure.data/diff should cope with null and false values in maps</title>
                <link>http://dev.clojure.org/jira/browse/CLJ-1011</link>
                <project id="10010" key="CLJ">Clojure</project>
                        <description>&lt;p&gt;Current behaviour of clojure.data/diff:&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;=&amp;gt; (diff {:a &lt;span class=&quot;code-keyword&quot;&gt;false&lt;/span&gt;} {:a &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;})
(nil {:a &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;} nil)
=&amp;gt; (diff {:a &lt;span class=&quot;code-keyword&quot;&gt;false&lt;/span&gt;} {:a nil})
(nil nil nil)&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Proposed behaviour:&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;=&amp;gt; (diff {:a &lt;span class=&quot;code-keyword&quot;&gt;false&lt;/span&gt;} {:a &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;})
({:a &lt;span class=&quot;code-keyword&quot;&gt;false&lt;/span&gt;} {:a &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;} nil)
=&amp;gt; (diff {:a &lt;span class=&quot;code-keyword&quot;&gt;false&lt;/span&gt;} {:a nil})
({:a &lt;span class=&quot;code-keyword&quot;&gt;false&lt;/span&gt;} {:a nil} nil)&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</description>
                <environment></environment>
            <key id="15527">CLJ-1011</key>
            <summary>clojure.data/diff should cope with null and false values in maps</summary>
                <type id="1" iconUrl="http://dev.clojure.org/jira/images/icons/bug.gif">Defect</type>
                                <priority id="4" iconUrl="http://dev.clojure.org/jira/images/icons/priority_minor.gif">Minor</priority>
                    <status id="6" iconUrl="http://dev.clojure.org/jira/images/icons/status_closed.gif">Closed</status>
                    <resolution id="1">Completed</resolution>
                                <assignee username="-1">Unassigned</assignee>
                                <reporter username="phiipa">Philip Aston</reporter>
                        <labels>
                        <label>enhancement</label>
                        <label>patch</label>
                    </labels>
                <created>Tue, 12 Jun 2012 05:04:16 -0500</created>
                <updated>Sat, 18 Aug 2012 07:12:52 -0500</updated>
                    <resolved>Sat, 18 Aug 2012 07:12:52 -0500</resolved>
                            <version>Release 1.3</version>
                <version>Release 1.4</version>
                                <fixVersion>Release 1.5</fixVersion>
                                        <due></due>
                    <votes>0</votes>
                        <watches>2</watches>
                        <comments>
                    <comment id="28779" author="phiipa" created="Tue, 12 Jun 2012 05:04:58 -0500"  >&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt; 
From e03a8060214d122ea2ebadf9e8a368f7f593d9f4 Mon Sep 17 00:00:00 2001
From: Philip Aston &amp;lt;philipa@mail.com&amp;gt;
Date: Sun, 10 Jun 2012 13:11:36 +0100
Subject: [PATCH] clojure.data/diff: cope with falsey values in maps

---
 src/clj/clojure/data.clj           |   18 +++++++++++++++++-
 test/clojure/test_clojure/data.clj |    3 ++-
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/src/clj/clojure/data.clj b/src/clj/clojure/data.clj
index 6e8dbcf..345b234 100644
--- a/src/clj/clojure/data.clj
+++ b/src/clj/clojure/data.clj
@@ -30,6 +30,22 @@
      (vec (repeat (apply max (keys m))  nil))
      m)))
 
+(defn- diff-associative-key
+  &quot;Diff associative things a and b, comparing only the key k.&quot;
+  [a b k]
+  (let [va (get a k)
+        vb (get b k)
+        [a* b* ab] (diff va vb)
+        in-a (contains? a k)
+        in-b (contains? b k)
+        same (and in-a in-b
+                  (or (not (nil? ab))
+                      (and (nil? va) (nil? vb))))]
+    [(when (and in-a (or (not (nil? a*)) (not same))) {k a*})
+     (when (and in-b (or (not (nil? b*)) (not same))) {k b*})
+     (when same {k ab})
+     ]))
+
 (defn- diff-associative
   &quot;Diff associative things a and b, comparing only keys in ks.&quot;
   [a b ks]
@@ -38,7 +54,7 @@
      (doall (map merge diff1 diff2)))
    [nil nil nil]
    (map
-    (fn [k] (map #(when % {k %}) (diff (get a k) (get b k))))
+    (partial diff-associative-key a b)
     ks)))
 
 (defn- diff-sequential
diff --git a/test/clojure/test_clojure/data.clj b/test/clojure/test_clojure/data.clj
index 9bab766..5a241e0 100644
--- a/test/clojure/test_clojure/data.clj
+++ b/test/clojure/test_clojure/data.clj
@@ -27,5 +27,6 @@
        [#{1} #{3} #{2}] (HashSet. [1 2]) (HashSet. [2 3])
        [nil nil [1 2]] [1 2] (into-array [1 2])
        [nil nil [1 2]] (into-array [1 2]) [1 2]
-       [{:a {:c [1]}} {:a {:c [0]}} {:a {:c [nil 2] :b 1}}] {:a {:b 1 :c [1 2]}} {:a {:b 1 :c [0 2]}}))
+       [{:a {:c [1]}} {:a {:c [0]}} {:a {:c [nil 2] :b 1}}] {:a {:b 1 :c [1 2]}} {:a {:b 1 :c [0 2]}}
+       [{:a nil} {:a false} {:b nil :c false}] {:a nil :b nil :c false} {:a false :b nil :c false}))
 
-- 
1.7.9.5
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt; 
</comment>
                    <comment id="28782" author="jafingerhut" created="Tue, 12 Jun 2012 12:43:02 -0500"  >&lt;p&gt;Philip, thanks for writing that patch.  Could you please attach it as a file to this ticket, instead of copying and pasting it into a comment?  Instructions are under the heading &quot;Adding patches&quot; on this page:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://dev.clojure.org/display/design/JIRA+workflow&quot;&gt;http://dev.clojure.org/display/design/JIRA+workflow&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Rich Hickey&apos;s policy is only to include code in Clojure that is written by those who have signed a contributor agreement.  You can find out more at &lt;a href=&quot;http://clojure.org/contributing&quot;&gt;http://clojure.org/contributing&lt;/a&gt;&lt;/p&gt;</comment>
                    <comment id="28783" author="phiipa" created="Tue, 12 Jun 2012 14:51:07 -0500"  >&lt;p&gt;Thanks Andy. Patch attached: &lt;/p&gt;

&lt;p&gt;0001-clojure.data-diff-cope-with-falsey-values-in-maps.patch&lt;/p&gt;

&lt;p&gt;I&apos;ll send in a CA.&lt;/p&gt;</comment>
                    <comment id="28828" author="phiipa" created="Sat, 16 Jun 2012 05:27:29 -0500"  >&lt;p&gt;CA snail-mailed yesterday, I guess it will take a week to arrive.&lt;/p&gt;</comment>
                    <comment id="28891" author="phiipa" created="Sat, 23 Jun 2012 05:00:17 -0500"  >&lt;p&gt;I now have a CA in place.&lt;/p&gt;</comment>
                    <comment id="29013" author="stu" created="Fri, 20 Jul 2012 16:51:32 -0500"  >&lt;p&gt;Yeah, this should be fixed.&lt;/p&gt;</comment>
                    <comment id="29158" author="aaron" created="Tue, 14 Aug 2012 21:42:01 -0500"  >&lt;p&gt;Patch applies cleanly against 4004d267e124f12b65b0d7fb6522f32a75e3c4fb. Submitter is a confirmed CA signer.&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                    <attachment id="11311" name="0001-clojure.data-diff-cope-with-falsey-values-in-maps.patch" size="2164" author="phiipa" created="Tue, 12 Jun 2012 14:48:44 -0500" />
                </attachments>
            <subtasks>
        </subtasks>
                <customfields>
                                <customfield id="customfield_10002" key="com.atlassian.jira.plugin.system.customfieldtypes:select">
                <customfieldname>Approval</customfieldname>
                <customfieldvalues>
                        <customfieldvalue key="10007">Ok</customfieldvalue>

                </customfieldvalues>
            </customfield>
                                                                                    <customfield id="customfield_10010" key="com.pyxis.greenhopper.jira:gh-global-rank">
                <customfieldname>Global Rank</customfieldname>
                <customfieldvalues>
                    
                </customfieldvalues>
            </customfield>
                                            <customfield id="customfield_10000" key="com.atlassian.jira.plugin.system.customfieldtypes:select">
                <customfieldname>Patch</customfieldname>
                <customfieldvalues>
                        <customfieldvalue key="10002">Code and Test</customfieldvalue>

                </customfieldvalues>
            </customfield>
                                                                                        </customfields>
    </item>
</channel>
</rss>