# HG changeset patch # User Mahlon E. Smith # Date 1450136588 28800 # Node ID 4450ba4a09374d3f40c391455926a8c6501af3a6 # Parent 5b4ee98d698cd8feeb72f03612aaf89dc8c8e129# Parent cee945391bf2fbbf9960b99c61f6762e469c78a0 branch merge diff -r cee945391bf2 -r 4450ba4a0937 lib/thingfish/metastore/pggraph.rb --- a/lib/thingfish/metastore/pggraph.rb Thu Nov 05 18:44:43 2015 +0000 +++ b/lib/thingfish/metastore/pggraph.rb Mon Dec 14 15:43:08 2015 -0800 @@ -24,7 +24,7 @@ # Package version - VERSION = '0.1.0' + VERSION = '0.1.1' # Version control revision REVISION = %q$Revision$ @@ -175,7 +175,8 @@ ### specified +oid+. def fetch_value( oid, key ) metadata = self.model[ oid ] or return nil - return metadata.send( key ) + key = key.to_sym + return metadata[ key ] || metadata.user_metadata[ key ] end @@ -200,6 +201,8 @@ ds = self.apply_search_direction( ds, options ) ds = self.apply_search_limit( ds, options ) + self.log.debug "Dataset for search is: %s" % [ ds.sql ] + return ds.map {|row| row[:id] } end @@ -276,7 +279,8 @@ def apply_search_order( ds, options ) if options[:order] columns = Array( options[:order] ) - ds = ds.order( columns.map(&:to_sym) ) + self.log.debug " ordering results by columns: %p" % [ columns ] + ds = ds.order_metadata( columns ) end return ds diff -r cee945391bf2 -r 4450ba4a0937 lib/thingfish/metastore/pggraph/node.rb --- a/lib/thingfish/metastore/pggraph/node.rb Thu Nov 05 18:44:43 2015 +0000 +++ b/lib/thingfish/metastore/pggraph/node.rb Mon Dec 14 15:43:08 2015 -0800 @@ -69,6 +69,24 @@ end + ### Dataset method: Order results by the specified +columns+. + ### + def order_metadata( *columns ) + columns.flatten! + ds = self + columns.each do |column| + if Thingfish::Metastore::PG::Metadata.metadata_columns.include?( column.to_sym ) + ds = ds.order_append( column.to_sym ) + else + ds = ds.order_append( self.user_metadata_expr(column) ) + end + end + + return ds + end + + + ######### protected #########