Committed.<br><br><div class="gmail_quote">On Nov 20, 2007 12:56 PM, Jesse Vincent &lt;<a href="mailto:jesse@bestpractical.com">jesse@bestpractical.com</a>&gt; wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
It&#39;s a fairly hairy codepath, but having it covered is better than not.<br><br>+1<br><div><div></div><div class="Wj3C7c"><br><br>On Tue, Nov 20, 2007 at 12:20:14PM -0600, Andrew Sterling Hanenkamp wrote:<br>&gt; So, my first patch was crap. It was actually failing because of a number of
<br>&gt; typos. However, I have a second patch that both reveals the problem and now<br>&gt; fixes it, I think. I&#39;m dropping it here to get feedback on how it looks,<br>&gt; mostly because the new second-run.t test I&#39;ve added to
<br>&gt; TestApp::DatabaseBackedModels is kind of kludgey and wondered if anybody had<br>&gt; a better way.<br>&gt;<br>&gt; The new second-run.t test checks to see if a second run of Jifty after Jifty<br>&gt; has been bootstrapped will load the models correctly. It does not in the
<br>&gt; current repository since collections aren&#39;t necessarily required before they<br>&gt; are used. To do this, I fork inside the test after including Jifty::Test to<br>&gt; bootstrap the database and run a second-run.pl
 child process with<br>&gt; essentially the same tests as bootstrap.t. In order to make the second run<br>&gt; work without bootstrapping, I&#39;ve also built a custom subclass of Jifty::Test<br>&gt; called TestApp::DatabaseBackedModels::Test that overrides setup() to run
<br>&gt; without the database setup and _testfile_to_dbname() so that the test will<br>&gt; use the same database as the parent process already bootstrapped.<br>&gt;<br>&gt; I could probably eliminate the need for TestApp::DatabaseBackedModels::Test
<br>&gt; with an environment flag similar to the JIFTY_FAST_TEST variable.<br>&gt;<br>&gt; Cheers,<br>&gt; Andrew<br>&gt;<br>&gt; On Nov 19, 2007 11:41 PM, Andrew Sterling Hanenkamp &lt;<a href="mailto:sterling@hanenkamp.com">
sterling@hanenkamp.com</a>&gt;<br>&gt; wrote:<br>&gt;<br>&gt; &gt; Jesse,<br>&gt; &gt;<br>&gt; &gt; I&#39;m working on a problem I&#39;ve discovered in the V-M branch. I&#39;ve attached<br>&gt; &gt; a patch that contains a new 
bootstrap.t test and modified <a href="http://Bootstrap.pm" target="_blank">Bootstrap.pm</a> for<br>&gt; &gt; TestApp::DatabaseBackedModels to reveal the basic issue. But here&#39;s the<br>&gt; &gt; jist. The patch basically modifies the existing boostrapper to add an
<br>&gt; &gt; additional &quot;Warehouse&quot; model similar to these declared models:<br>&gt; &gt;<br>&gt; &gt; package Warehouse;<br>&gt; &gt; schema {<br>&gt; &gt; &nbsp; column location =&gt; type is &#39;text&#39;;<br>&gt; &gt; &nbsp; column widgets =&gt; references WidgetCollection by &#39;warehouse&#39;;
<br>&gt; &gt; };<br>&gt; &gt;<br>&gt; &gt; package Widget;<br>&gt; &gt; schema {<br>&gt; &gt; &nbsp; column name =&gt; type is &#39;text&#39;;<br>&gt; &gt; &nbsp; column inventory =&gt; type is &#39;int&#39;;<br>&gt; &gt; &nbsp; column warehouse =&gt; references Warehouse;
<br>&gt; &gt; };<br>&gt; &gt;<br>&gt; &gt; This code when used works fine until you try to call the &quot;widgets&quot; method<br>&gt; &gt; of a &quot;Warehouse&quot; object. When you do that you get:<br>&gt; &gt;<br>&gt; &gt; WARN - DBD::SQLite::db prepare failed: no such column: widgets(1) at
<br>&gt; &gt; dbdimp.c line 271 at /Library/Perl/5.8.6/Jifty/DBI/Handle.pm line 474.<br>&gt; &gt; WARN - TestApp::DatabaseBackedModels::Handle=HASH(0x1f69ea8) couldn&#39;t<br>&gt; &gt; prepare the query &#39;SELECT widgets FROM warehouses WHERE id = ?&#39;no such
<br>&gt; &gt; column: widgets(1) at dbdimp.c line 271<br>&gt; &gt;<br>&gt; &gt; As you can see the anonymous subroutine used to define &quot;widgets&quot; is<br>&gt; &gt; incorrectly using a call to __value() to fetch the value rather than using
<br>&gt; &gt; _collection_value() as it should. I&#39;ve not pinned this all the way down yet,<br>&gt; &gt; but I&#39;m speculating that the issue is that the &quot;widgets&quot; column is being<br>&gt; &gt; defined prior to &quot;WidgetCollection&quot; becoming available inside
<br>&gt; &gt; Jifty::ClassLoader::require_classes_from_database().<br>&gt; &gt;<br>&gt; &gt; What I don&#39;t know is how to fix it, if this is indeed the case. I&#39;m<br>&gt; &gt; currently working my way through Jifty::DBI::Schema to understand how the
<br>&gt; &gt; _init_column() method and related code works to see if I can bring the same<br>&gt; &gt; or similar logic into the class loader, but I&#39;d be grateful for some advice.<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt; Cheers,
<br>&gt; &gt; Andrew<br>&gt; &gt;<br><br><br></div></div>&gt; _______________________________________________<br>&gt; jifty-devel mailing list<br>&gt; <a href="mailto:jifty-devel@lists.jifty.org">jifty-devel@lists.jifty.org
</a><br>&gt; <a href="http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-devel" target="_blank">http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-devel</a><br><font color="#888888"><br><br>--<br>_______________________________________________
<br>jifty-devel mailing list<br><a href="mailto:jifty-devel@lists.jifty.org">jifty-devel@lists.jifty.org</a><br><a href="http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-devel" target="_blank">http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-devel
</a><br></font></blockquote></div><br>