<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hello again,<div><br><div>I received some excellent feedback yesterday and was able to incorporate it into the code today, along with some significant refactoring and improved documentation. If you're interested please check out the most recent code:</div><div><a href="http://freebaseapi.rubyforge.org/svn/trunk/freebase/">http://freebaseapi.rubyforge.org/svn/trunk/freebase/</a></div><div><br class="webkit-block-placeholder"></div><div>or read the docs at:</div><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; "><a href="http://freebaseapi.rubyforge.org/svn/trunk/freebase/rdoc/index.html">http://freebaseapi.rubyforge.org/svn/trunk/freebase/rdoc/index.html</a></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; "><br class="webkit-block-placeholder"></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; ">New Features:</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; "><ul class="MailOutline"><li>No need to call Freebase::Type.define('/music/artist') before accessing Freebase::Types::Music::Artist (thanks to pat allan for this suggestion and code examples)</li><li>Ability to add custom methods to instances of Freebase types using a mixin and naming conventions.</li><li>Support for nested queries to retrieve multiple levels of associations in a single query</li></ul><div><br class="webkit-block-placeholder"></div><div>Open Questions/Concerns:</div><ul class="MailOutline"><li><font class="Apple-style-span" face="'Courier New'">:fb_object =&gt; true</font> should be added to the subquery whenever sub-querying an association so that a distinction can be drawn for the following differences in validation logic between object types and core types:</li><ul class="MailOutline"><li>objects have multi-valued types, core types do not and you may not query a core type with<font class="Apple-style-span" face="'Courier New'"> []</font> you have to use <font class="Apple-style-span" face="'Courier New'">null</font>.</li></ul><ul><li>values of core types do not have an id and you may not specify <font class="Apple-style-span" face="'Courier New'">'id' : null</font> in the query of a core type.</li></ul><li>In both of these cases, the validation seems arbitrarily enforced; returning <font class="Apple-style-span" face="'Courier New'">['/type/text']</font> and&nbsp;<font class="Apple-style-span" face="'Courier New'">'id':null </font>back respectively are in line with the other behaviors of the system, in my estimation.</li><li>I'm getting nulls from collections associations from Artist -&gt; Album and from Album -&gt; Track. I understand the null names problem now and am handling that appropriately per the recommendations in my new query. But I don't understand why a null would be returned as an element of an array. Please let me know whether to begin searching for a code defect on my end.</li></ul><div><br class="webkit-block-placeholder"></div><div>Thanks,</div><div>Chris</div><div><br class="webkit-block-placeholder"></div></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; ">The code example again using the latest api:</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; "><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; "><font class="Apple-style-span" face="'Courier New'"># Usage:</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; "><font class="Apple-style-span" face="'Courier New'">#&nbsp; ./script/runner vendor/plugins/freebase/examples/albums.rb "The Police"</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; min-height: 14px; "><font class="Apple-style-span" face="'Courier New'"><br></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; "><font class="Apple-style-span" face="'Courier New'"># add these methods to the Track class</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; "><font class="Apple-style-span" face="'Courier New'">module Freebase::Mixins::Music</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; "><font class="Apple-style-span" face="'Courier New'">&nbsp; module Track</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; "><font class="Apple-style-span" face="'Courier New'">&nbsp; &nbsp; def formatted_length</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; "><font class="Apple-style-span" face="'Courier New'">&nbsp; &nbsp; &nbsp; "#{self.length.to_i / 60}:#{sprintf("%02i", self.length.to_i % 60)}"</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; "><font class="Apple-style-span" face="'Courier New'">&nbsp; &nbsp; end</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; "><font class="Apple-style-span" face="'Courier New'">&nbsp; end</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; "><font class="Apple-style-span" face="'Courier New'">end</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; min-height: 14px; "><font class="Apple-style-span" face="'Courier New'"><br></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; min-height: 14px; "><font class="Apple-style-span" face="'Courier New'"><br></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; "><font class="Apple-style-span" face="'Courier New'">artist = Freebase::Types::Music::Artist.find(:first,</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; "><font class="Apple-style-span" face="'Courier New'">&nbsp; :conditions =&gt; {</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; "><font class="Apple-style-span" face="'Courier New'">&nbsp; &nbsp; :name =&gt; {:value =&gt; ARGV[0], :lang =&gt; {:name =&gt; "English"}},</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; "><font class="Apple-style-span" face="'Courier New'">&nbsp; &nbsp; :album =&gt; [{</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; "><font class="Apple-style-span" face="'Courier New'">&nbsp; &nbsp; &nbsp; :fb_object =&gt; true,</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; "><font class="Apple-style-span" face="'Courier New'">&nbsp; &nbsp; &nbsp; :name =&gt; {:value =&gt; nil, :lang =&gt; {:name =&gt; "English"}},</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; "><font class="Apple-style-span" face="'Courier New'">&nbsp; &nbsp; &nbsp; :release_date =&gt; nil,</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; "><font class="Apple-style-span" face="'Courier New'">&nbsp; &nbsp; &nbsp; :track =&gt; [{</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; "><font class="Apple-style-span" face="'Courier New'">&nbsp; &nbsp; &nbsp; &nbsp; :fb_object =&gt; true,</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; "><font class="Apple-style-span" face="'Courier New'">&nbsp; &nbsp; &nbsp; &nbsp; :length =&gt; nil,</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; "><font class="Apple-style-span" face="'Courier New'">&nbsp; &nbsp; &nbsp; &nbsp; :name =&gt; {:value =&gt; nil, :lang =&gt; {:name =&gt; "English"}}</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; "><font class="Apple-style-span" face="'Courier New'">&nbsp; &nbsp; &nbsp; }]</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; "><font class="Apple-style-span" face="'Courier New'">&nbsp; &nbsp; }]</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; "><font class="Apple-style-span" face="'Courier New'">&nbsp; }</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; "><font class="Apple-style-span" face="'Courier New'">)</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; min-height: 14px; "><font class="Apple-style-span" face="'Courier New'"><br></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; "><font class="Apple-style-span" face="'Courier New'">artist.albums.each_with_index do |album, i|</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; "><font class="Apple-style-span" face="'Courier New'">&nbsp; next unless album # XXX I don't know why I'm getting random nils here.</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; "><font class="Apple-style-span" face="'Courier New'">&nbsp; puts "#{i+1}) #{album.name} (#{album.release_date || '?'})"</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; "><font class="Apple-style-span" face="'Courier New'">&nbsp; album.tracks.compact.each_with_index do |track, j|</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; "><font class="Apple-style-span" face="'Courier New'">&nbsp; &nbsp; &nbsp; puts "\tT#{j+1}. #{track.name || '???'} (#{track.formatted_length})"</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; "><font class="Apple-style-span" face="'Courier New'">&nbsp; end</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; "><font class="Apple-style-span" face="'Courier New'">end</font></div></div></div><div><br class="webkit-block-placeholder"></div><div><br class="webkit-block-placeholder"></div></div></body></html>