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