changeset 1534:d4de13e83b7f

graph.js don't error if a statement is in multiple graphs Ignore-this: 6ba903b20b1177dea8e0c96d0ab67d6
author Drew Perttula <drewp@bigasterisk.com>
date Wed, 10 May 2017 07:00:22 +0000
parents c962f19c7328
children 04f2e93f04e3
files light9/web/graph.coffee
diffstat 1 files changed, 5 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/light9/web/graph.coffee	Wed May 10 04:12:10 2017 +0000
+++ b/light9/web/graph.coffee	Wed May 10 07:00:22 2017 +0000
@@ -225,14 +225,16 @@
   _singleValue: (s, p) ->
     @_autoDeps.askedFor(s, p, null, null)
     quads = @graph.findByIRI(s, p)
-    switch quads.length
+    objs = new Set(q.object for q in quads)
+    
+    switch objs.size
       when 0
         throw new Error("no value for "+s+" "+p)
       when 1
-        obj = quads[0].object
+        obj = objs.values().next().value
         return obj
       else
-        throw new Error("too many values: " + JSON.stringify(quads))
+        throw new Error("too many different values: " + JSON.stringify(quads))
 
   floatValue: (s, p) ->
     key = s + '|' + p