Fix criteria searches that include both 'relationship' and 'relation' fields.
authorMahlon E. Smith <mahlon@martini.nu>
Wed, 09 Nov 2016 22:38:18 -0800
changeset 8 1ad0d5bc5083
parent 7 f0ef12e25a2f
child 9 47425483883e
Fix criteria searches that include both 'relationship' and 'relation' fields.
lib/thingfish/metastore/pggraph.rb
lib/thingfish/metastore/pggraph/node.rb
--- a/lib/thingfish/metastore/pggraph.rb	Tue Nov 01 17:12:49 2016 -0700
+++ b/lib/thingfish/metastore/pggraph.rb	Wed Nov 09 22:38:18 2016 -0800
@@ -24,7 +24,7 @@
 
 
 	# Package version
-	VERSION = '0.1.2'
+	VERSION = '0.1.3'
 
 	# Version control revision
 	REVISION = %q$Revision$
--- a/lib/thingfish/metastore/pggraph/node.rb	Tue Nov 01 17:12:49 2016 -0700
+++ b/lib/thingfish/metastore/pggraph/node.rb	Wed Nov 09 22:38:18 2016 -0800
@@ -54,9 +54,11 @@
 				#
 				else
 					if field.to_sym == :relationship
-						ds = self.join_edges.filter( Sequel.pg_jsonb( :edges__prop ).get_text( field.to_s ) => value )
+						ds = ds.join_edges unless ds.joined_dataset?
+						ds = ds.filter( Sequel.pg_jsonb( :edges__prop ).get_text( field.to_s ) => value )
 
 					elsif field.to_sym == :relation
+						ds = ds.join_edges unless ds.joined_dataset?
 						ds = self.join_edges.filter( :edges__id_p => value )
 
 					else